PHP Menu Driven Application Part – 2

Program 1

<html>
<body>
    <center>
        <table border=1>  
            <tr bgcolor=yellow><th >------------Menu Application----------</th></tr>
            <tr bgcolor=cyan>
                <td>1. Factorial Of Number</td>
           </tr>
           <tr bgcolor=green>
                <td>2. Reverse Of Number</td>
           </tr>
           <tr>
                <td>3. Palindrom Number</td>
           </tr>
           <tr bgcolor=blue>
                <td>4. Armstrong Number</td>
           </tr>
          <tr>
            <td>Enter Your choice
                <form method=post action=MenuApplication.php>
                 <input type=text name=txtchoice>
                 <input type=submit value=submit name=btnsubmit>
                </form>  
             </td> 
          </tr>  
</table>  
<pre>
  
<?php
    if(isset($_POST['btnsubmit']))
    { 
            $choice=$_POST['txtchoice'];
            switch($choice) 
            {
                case 1: 
                    {
                            header("Location:factorial.php");
                            break;
                    }     
                case 2:     
                    {
                        header("Location:reverse.php");
                        break;
                   }      
                   case 3:     
                    {
                        header("Location:palindrom.php");
                        break;
                   }
                   case 4:     
                    {
                        header("Location:armstrong.php");
                        break;
                   }
                 default:echo "<font color=red size=5>Invalid choice</font>"; 
                    
            }

    }

?>
</pre>
</center>

Program 2

<?php  include 'MenuApplication.php'?>
<html>
    <head><title>Palindrome Page</title></head>
   <body>
    <center>
        <br><h5>Enter A Number to check palindrom</h4>
           <form method=post action=palindrom.php>
                 <input type=text name=txnumber>
                 <input type=submit value=submit name=btnsubmit1>
    </form> 
<?php 
        if(isset($_POST['btnsubmit1']))
        { 
               $n=$_POST['txnumber'];
               $m=$n;
               $r;
               $s=0;
               while($n!=0)    
            {
              $r=($n%10);   
              $s=$s*10+$r;   
              $n=(int)($n/10); 
            }    
              if($m==$s)
                echo "<font color=green size=5> Number is palindrom</font>";
            else
            echo "<font color=red size=5> Number is not palindrom</font>";
        }     
 ?>
<center>
</body>     
</html>

Program 3

<?php  include 'MenuApplication.php'?>
<html>
    <head><title>Palindrome Page</title></head>
   <body>
    <center>
        <br><h5>Enter A Number to check armstrong</h4>
           <form method=post action=armstrong.php>
                 <input type=text name=txnumber>
                 <input type=submit value=submit name=btnsubmit1>
    </form> 
<?php 
        if(isset($_POST['btnsubmit1']))
        { 
               $n=$_POST['txnumber'];
               $m=$n;
               $r;
               $s=0;
               while($n!=0)    
            {
              $r=($n%10);   
              $s=$s+($r*$r*$r);   
              $n=(int)($n/10); 
            }    
              if($m==$s)
                echo "<font color=green size=5> Number is armstroing</font>";
            else
            echo "<font color=red size=5> Number is not armstrong</font>";
        }     
 ?>
<center>
</body>     
</html>

Program 4

<?php  include 'MenuApplication.php'?>
<html>
    <head><title>Reverse Page</title></head>
   <body>
    <center>
        <br><h5>Enter A Number for Reverse of Number</h4>
           <form method=post action=reverse.php>
                 <input type=text name=txnumber>
                 <input type=submit value=submit name=btnsubmit1>
    </form> 
<?php 
        if(isset($_POST['btnsubmit1']))
        { 
               $n=$_POST['txnumber'];
               $r;
               $s=0;
               while($n!=0)    
            {
              $r=($n%10);   
              $s=$s*10+$r;   
              $n=(int)($n/10); 
            }    
               echo "<font color=blue size=5> Reverse is: ".$s."</font>";
        }     
 ?>
<center>
</body>     
</html>

 

courses
Image

TechVidvan Team

TechVidvan Team provides high-quality content & courses on AI, ML, Data Science, Data Engineering, Data Analytics, programming, Python, DSA, Android, Flutter, full stack web dev, MERN, and many latest technology.

Leave a Reply

Your email address will not be published. Required fields are marked *