Saturday, August 27, 2022

CALCULATOR PHP

MULTIPLE BUTTON USE

<?php
$name=$_GET['n1']
?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title></title>
</head>
<body style="background-color: <?php echo $name;?>">
    <h1>PHP CALCULATOR</h1>
    <form action="demo.php">
<input type="color" name="n1">
<input type="submit" value="submit" name="">
</form><br>
    <form action="demo.php" method="GET">
    Enter value : <input type="text" name="t1">
    <br> <br>
    Enter value : <input type="text" name="t2">
    <br><br>
    <input type="submit" value="SUM" name="sum">
    <br><br>
    <input type="submit" value="SUB" name="sub">
    <br><br>
    <input type="submit" value="DIVIDE" name="div">
    <br><br>
    <input type="submit" value="MULTIPLY" name="mul">
    <br><br>
</from>
</body>
</html>
<?php
if (isset($_GET['sum'])) {
$num= $_GET['t1'];
$num1= $_GET['t2'];
echo "sum=".($num + $num1);
 }
if (isset($_GET['sub'])) {
$num= $_GET['t1'];
$num1= $_GET['t2'];
echo "sub=".($num - $num1);
 }
if (isset($_GET['div'])) {
$num= $_GET['t1'];
$num1= $_GET['t2'];
echo "Division=".($num / $num1);    
 }
if (isset($_GET['mul'])) {
$num= $_GET['t1'];
$num1= $_GET['t2'];
echo "Multiply=".($num * $num1);    
 }
?>

 

String Function PHP

LOGIN 

 <form action="login.php" method="get">  Enter the password:<input type="password" name="pass" ><input type="submit" name="submit" ></form>

<?php

if (isset($_GET['submit'])){
    $var =$_GET['pass'];}
if((strlen($var))<=7){
    echo "Password should be lenght";}
else{
    echo "login";}
?>

SEARCHING STRING
<form action="string.php" method="get">
    Enter name:<input type="text" name="name" >
<input type="submit" name="submit" >
</form>
<?php
if (isset($_GET['submit']))
{
if (strlen($_GET['name'])<=7) {
    echo "Must be use & lenght of string"; }
else{
    echo "complete";
}}
?>

<h1>WORD COUNT CONDITION STRING</h1>
<form>
 enter name:-<input type="text" name="name">
 <input type="submit" name="click">
</form>
<?php
if (isset($_GET['click'])) {
$i=str_word_count($_GET['name']);
if ($i>1) {
 echo "you should be enter only single name";}
else 
{echo "complete";}}
?>

<h1>SPECIFIC WORD PRINT @ STRING</h1>
<form>
 enter name:-<input type="text" name="name">
 <input type="submit" name="click" value="enter">
</form>
<?php
if (isset($_GET['click'])) {
    $i=str_word_count($_GET['name']);
    echo (strstr($_GET['name'],"@")?"yes":"No")."<br>";}
?>

<h1>WORD COUNT STRING</h1>
<form>
 enter name:-<input type="text" name="name">
 <input type="submit" name="click">
</form>
<?php
if (isset($_GET['click'])) {
 echo "total number of words are here=".str_word_count($_GET['name']);}
?>

<h1>SPECIFIC WORD PRINT STRING</h1>
<form>
 enter name:-<input type="text" name="name">
 <input type="submit" name="click" value="enter">
</form>
<?php
if (isset($_GET['click'])) {
    $i=str_word_count($_GET['name']);
    echo strstr($_GET['name'],"kumar");}
?>

Sunday, August 7, 2022

DATA FORM PHP

<?php
$name=$_GET['n1']
?>
<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body style="background-color: <?php echo $name;?>">
<h1>Fill your Registration form of IICS</h1>
<form action="ger.php" method="post">
<label for="firstname">First name</label>
<input type="text" name="firstname"><br><br>   
<label for="lastname">Last name</label>
<input type="text" name="lastname"><br><br>
<label for="password1">Choose a password</label>
<input type="password" name="password1"><br><br>
<label for="password2">Retype password</label>
<input type="password" name="password2"><br><br>
<label for="gender">Your Gender?</label>
<input type="radio" value="Male" name="gender">Male
<label for="gender"></label>
<input type="radio" value="Female" name="gender">Female<br><br>
<label for="cr">Which Course you select</label>
<select name="cr">
    <option value="ADCE">ADCE</option>
    <option value="WD+ECO">WD+ECO</option>
    <option value="DCA">DCA</option>
</select><br><br>
<label for="class">Attend trial classes?</label>
<input type="checkbox" name="class" value="yes"><br><br>
<label for="comment">Comment</label>
<textarea name="comment" rows="4" cols="50" placeholder="optional"></textarea><br><br>
<input type="Submit">
</form><br><br><br>
<form action="Eform.php">
<input type="color" name="n1">
<input type="submit" value="submit" name="">
</form>
</body>
</html>  


php coding here
<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
<h1>Submitted Form Data</h1>
<p>Thankyou for registering. There is the information you submitted:</p>
<dl>
<dt>First name:</dt><dd><?php echo $_POST["firstname"]?></dd>    
<dt>Last name:</dt><dd><?php echo $_POST["lastname"]?></dd>
<dt>Password:</dt><dd><?php echo $_POST["password1"]?></dd>
<dt>Retype Password:</dt><dd><?php echo $_POST["password2"]?></dd>
<dt>Gender:</dt><dd><?php echo $_POST["gender"]?></dd>
<dt>Which Course you select:</dt><dd><?php echo $_POST["cr"]?></dd>
<dt>Attend trial classes?:</dt><dd><?php echo $_POST["class"]?></dd>
<dt>Comment:</dt><dd><?php echo $_POST["comment"]?></dd>
</dl>
</body>
</html>

Monday, August 1, 2022

Php functions

 <h3>Odd even programme</h3>
<?php
function user()
{
for ($i=0; $i<=10 ; $i++) 

if ($i%2==0) 
{
echo "even=".$i."<br>";
}
else
{
echo "odd=".$i."<br>";
}
}
}
user();
?>
<h3>With argument with return type</h3>
<?php
  function student($a,$b)
  {
echo "we are in student function <br>";
 echo "a=$a b=$b<br>";
echo "sum of number a+b=($a+$b)<br>";
  $avg=($a+$b)%2;
  return $avg;
  }
  function teacher()
  {
  $a=student(20,40);
echo "<br>we are inside teacher  function<br>";
echo "<br>avg=$a";
  }
    teacher ();
?>
<h3>Without argument with return type:-</h3>
<?php
  function student()
  {
 $a=90;
 $b=80;
 $sum=$a+$b;
 echo "a=$a b=$b<br>";
echo "sum of a+b is=$sum<br>";
  return $sum%2;
  }
  $avg=student();
echo "avg=$avg<br>";
?>

Php Array

 <h2>Array</h2>

<?php

$ar=array(array(102,"shiva",50,60,120), 

    array(103,"shiva",50,64,120),

    array(104,"shiva",50,67,120),

    array(105,"shiva",50,623,120));


 for ($i=0; $i<4; $i++) 

 { 

        for ($j=0; $j<4; $j++) 

        { 

            echo "".$ar[$i][$j];

        }

        echo "<br>";

        }       

?>

<h3>For each for table use</h3>

<?php

$ar=array(102,"jatin",50,60,120);

echo "<table border=1><tr>";

foreach ($ar as $i) {

    echo "<tr><td>".$i."</td></tr>";

}

echo "</tr></table>";

?>


<h3>For each loop use for nested foreach</h3>

<?php

$ar=array(array(192,'shiva',50,39,17),

array(192,'shiva',50,39,17),

array(192,'shiva',50,39,17),

array(192,'shiva',50,39,17));

echo"<table border=1  bordercolor=red>";

foreach ($ar as $i) {

    echo "<tr>";

foreach ($i as $j) {

echo "<td>".$j."</td>";

}

echo "</tr>";}

echo "</table>";

?>

Php form

 <!DOCTYPE html>

<html>

<head>

<title></title>

</head>

<body>

<form action="self.php">

Name:<input type="text" name="t1"><br>

Age:<input type="number" name="t2"><br>

    Email Address:<input type="text" name="t3"><br>

    Password:<input type="password" placeholder="Enter Your password here" name="t4"><br>

    <input type="submit" name="submit">

</form>

</body>

</html>

<?php

if (isset($_GET['submit'])) {

    echo "Name:-".$_GET['t1']."<br>";

    echo "Age:-".$_GET['t2']."<br>";

    echo "Email:-".$_GET['t3']."<br>";

    echo "Password:-".$_GET['t4']."<br>"; 

}

?>