ad

Friday, May 24, 2024

PHP program palindrome number

 palindrome number in php

 

palindrome number in php

palindrome number  ::-

1] palindrome number is a number which remains same digits reversed.

2] eg ::- number - 24142 is a palindrome number. 

 on reversing same digits .


1) take a number .

 2) Reverse the input digits.

3) compare the two digits.

4) If equal it is digits is palindrome. 


 palindrome number in php

Example ::-

<?php
function palindrome($n){
    $number =$n;
    $sum = 0;
    while(floor($number))
    {
        $rem = $number % 10;
        $sum = $sum * 10+$rem;
        $number = $number/10;

    }
  return $sum;
}
$input= 1235321;
$num= palindrome($input);
if($input==$num){
echo "$input is a palindrome number";
}
else {
    echo "$input is not a palindrome";
   
}


?>

 palindrome number in php 

Output ::- 

·        Palindrome Number use in  form in php

Example :-

<form method="post">
    Enter a number
    <input text="text" name="number">
    <br></br>
    <button type="submit">Check number</button>
</form>
<?php
if($_POST)
{
    $number=$_POST['number'];
    $reverse=strrev($number);
    if($number==$reverse){
        echo"The number  $number is polindrome";
    }
    else{
        echo"The number $number is not a
polindrom";

    }
    }
?>

   Output :-



 Recommended Articles 

Wednesday, May 22, 2024

how to run php program

 How To Run A PHP Code In  XAMPP

how to run php program


How to Install XAMPP ?


 1]   Apachefriends developed XAMPP . 

2] XAMPP available for everyone free of cose,

 3] download XAMPP through the official website

     https://www.apachefriends.org/download.html

  completing the download of the  setup file, than installation process  "select components"             section , select all the required components.

 setup




  ∴ Next, Select the directory where you want the software to be installed.it is recommended that you 
      use default directory "c\xampp" and click on "next " to complete the installation.


How to Start a New PHP Program In XAMPP ?

1]  Before you run or start  writing any program in php ,you start Apache & MYSQL.

2] next starting both servers, you have to write a program in Notepad, visual studio code ...... etc.

3]  next writing it, save that file  Name  as "program.php".

4] Before copy that file program.php to c:/program Files/ XAMPP/htdocs.

5]  open the browser and type http://localhost.

6]  Now run your code in that browser. 

 How to Run  a PHP Code using XAMPP?

 1] Before running a php script, you must know anywhere to write it.  

2]  XAMPP directory, there exists a folder called "htdocs" This is Where all the programs for 
     The web pages will be stored.

3]   Now, run a PHP Script.

1]  Go to "C:\xampp\htdocs" and inside it, create a  folder. lets  call it  "demo" it's considered 
     good practice to create  a new folder for every project you work on. 


2] Inside the demo folder, create a new text file and name it "index.php" and write the following script.

  
<?php
echo " hi";
?>
<?+php
echo "<marquee>learn php language </marquee>" ;
?>


3] Now to see the script  output open the XAMPP  control panel  and start Apache to host the local 
   webserver, where our script will be running.




4] Now navigate to your browser and type in "localhost/demo/" in the address bar to view the 

∴  OUTPUT  :


 Congratulations with this  you have  created a PHP  file and also executed the          program Successfully.


1) Can we run PHP in XAMPP? 

Yes, you can run PHP  in xampp. First start the XAMPP Server create a program  you want to and  run  http://localhost.


2) How do I run my PHP file?

PHP  files are saved in c:/program  files/XAMPP/htdocs.
you have to open it. click on the program, and it will automatically run on localhost.

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 :--


Related post ::::-

javascript do while loop

php course online

forgot password form


Saturday, May 4, 2024

php program check to even or odd number


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



Related Post :-

php else if ladder

line break html

how to create login forms

    
 



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


Related Post :-


php program factorial number program

php program to print alphabet pattern B

php for loop