Sunday, May 5, 2024

php program to check whether a number is positive or negative

Check whether a number 

php program to check whether a number is positive or negative

Q. program to check whether a number is positive or negative or Zero 

Example ::-

<?php

$no=49;
$result=($no>0)? "positive no":"Negative no" ;
echo $result;

?>

 output ::-

positive no 


Q. php program to check whether a number is positive or negative or Zero 

Form.  

Example

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="
width=device-width, initial-scale=1.0">
    <link rel ="stylesheet" href="
css/bootstrap.css">
    <title>Document</title>
</head>
<body class="bg-primary">
<div class="bg-white col-md-4 mx-auto mt-5 p-3">
<h5>positive/negative /zero</h5>
    <form action="accept-posi-nega-no.php"
method="get">
    <label>enter any no</label>    
    <input type="number" name="no" class="
form-control" required>
    <input type="submit" value="check" name="b1"
class="btn-btn-primary mt-2">

    </form>
    <?php
        if(isset($_GET['b1']))
        {
            $number=$_GET['no'];
       
        if($number>0)
        {
            echo"positive no";
        }
        else if ($number<0)
        {
            echo"negative";
        }
        else
        {
            echo "no is zero";
        }
    }


       
    ?>
    </div>
</body>
</html>


 php program to check whether a number is positive or negative or Zero 

Form . 

Output :--


Read More:::-

how to run php program

php introduction

php data type

php comparison operators

php logical operators

php array type







Saturday, May 4, 2024

php even odd program


Even odd Program


php even odd program

php even odd program

Information ::-

1]  Those EVEN Number  - 2,4,6,8,10 etc.
2] those divisible by 2 number .


1] Those ODD Number - 1,3,5,7,9,11 etc.
2]  Not divisible by  2 Number .

PHP Even Odd Program 

Example :-

<?php
$no=100;
if($no%2==0)
{
    echo"$no is even number";
}
else
{
  echo "$no is odd number";
}
?>

php even odd program

Output :-

php even odd program /output

Even odd Program using FORM in php 

Example :-



<form action="evenor-odd-form.php" method="get">
    <input type="number"  name="number" value="number" required>
    <input type="submit" value="show" name="b1">  
</form>
<?php

  if(isset($_GET['b1']))
  {
  /* input  */
  $no =$_GET ['number'];
 

  $result=($no %2==0)? "no even" :"no odd";
  echo "$result";
  }
  ?>


Even odd Program using FORM in php 

Output :-

php even odd program /output



Read more 

how to create login form in php

registration form in php

php form handling

php echo

php array types

php while loop

    
 



Thursday, May 2, 2024

how to create login form in php

        

     how to create login form in php with MySQL

Registration form  in php


Login Form 

      EXAMPLE :-




<?php
include 'connection.php';
        if(isset($_POST['b1']))
        {
           
            $email = $_POST['uem'];
            $pass = $_POST['upwd'];
    $q="SELECT * FROM userdetails WHERE uem =
'$email' AND upwd ='$pass'";

            $rs = mysqli_query($cn,$q);
            $count = mysqli_num_rows($rs);

                if($count ==1)
                {
                    session_start();//start
            $data = mysqli_fetch_assoc($rs);
                   
      $_SESSION['id'] = $data['uid'];//create
                    echo "<script>
                    alert('login Successfully');
          window.location.href='profile.php';
                    </script>";
                }
                else
                {
                    echo "<script>
                  alert('Invalid Credetials');
                    </script>";
                }

        }

?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content=
"width=device-width, initial-scale=1.0">
    <title>User Login</title>
    <link rel="stylesheet"
href="css/bootstrap.css">
</head>
<body class="">

       
   
  <div class="col-md-4 bg-white shadow-lg
mx-auto mt-5
        p-3">
           
        <h1 class="text-center text-primary">
                Login Here
            </h1>

      <form action="login.php" method="post">
           

            <label>Email Address</label>
<input type="email" name="uem" class="
form-control mb-1"
            required>

            <label>Password</label>
            <input type="password" name="upwd"
class="form-control mb-1"
            required>

         
            <div class="text-center">
          <input type="submit" value="Login"
           name="b1" class="btn btn-primary">

  <a href="index.php" class="btn btn-danger">
Create An account ?</a>


                <br>

                <p class="text-center my-3">
                    <a href="forgot-password.php">
                        forgot password ?
                    </a>
                </p>
            </div>
            </form>
        </div>
</body>
</html>

Login Form 


         Output:-

           PHP FORM (USE TO BOOTSTRAP)/output

Note :- data store in the database php


   Read more 


registration form php

php form handling

php echo

php Comments tag