PHP PRACTICAL SLIP PROGRAMS




 PHP PRACTICAL SLIP PROGRAMS


Slip 1






<!DOCTYPE html>

 <html>

  <head>

<title> Myform</title>

<style>

h1{

    font-size : 6px;

color : red;

}

body{

     background-color:yellow;

}

</style>

  </head>

 

  <body >

   <form >

     <center>

   

  <label for="pname">  Project Name : </label>

  <input type = "text" name = "pname" id = "pname" placeholder="event management system">    <BR>

  

  <label for="ass">  Assigned to : </label>

  <input type = "text" name = "ass" id = "ass" placeholder="Dr. Merry Petision">    <BR>



  <label for="sdate">  Start Date : </label>

  <input type = "date" name = "sdate" id = "sdate" placeholder="dd-mm-yyyy">    <BR>

<label for="edate">  End Date : </label>

  <input type = "date" name = "edate" id = "edate" placeholder="dd-mm-yyyy">    <BR>

  

   Priority:

   <input type = "radio" name = "pri" id = "pri" >  

    <label for="pri">  High : </label> 

   <input type = "radio" name = "pri" id = "pri" >  

    <label for="pri">  Average : </label>  

   <input type = "radio" name = "pri" id = "pri" >  

    <label for="pri">  Low : </label>      <BR>

   <label for="txt">  Description : </label>  

<input type = "text" name = "txt" id = "txt" >  <BR>  

   

<input type="submit" value = "submit" color="red" >

  <input type = "reset" value = "reset">

  

</center>

 </form>

</body>

</html>


 OUTPUT:






Priority:    
 



Slip 2

<!-- Create HTML5 page with following specifications [15]

i) Title should be about your City. 

ii) Color the background by Pink color. 

iii) Place your city name at the top of page in large text and in blue color. 

iv) Add names of the landmarks in your city, each in different color, style and font 

v) Add any image at the bottom. (Use inline CSS to format the web page)

--->



<!DOCTYPE html>

 <html>

  <head>

<title> Myform</title>

  </head>

 

  <body bgcolor="pink">

  

     <center> <h1 style ="color:blue; font-size:80px"> Pune </h1> </center>

 

      <center> <p style ="color:black; font-size:50px"> Landmarks: </p> </center>


      <center> <p style ="color:green; font-size:40px"> Baramati </p> </center>

  <center> <p style ="color:white; font-size:40px"> Daund </p> </center>

      <center> <p style ="color:yellow; font-size:40px"> supe </p> </center>

 

    <center>

       <img src = "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIVgiC5Fl_RHYYMB-ollVfpN3nAhRkmMtfIo4yQUJ_gQkCQPwswWODuVjiBcbMiBipZyeACZw8XTWsVkMyREbwCpiNIVv04LB9idNV3F3Q0aOfy_Rm_u_oYThlZeZWAehiR5okZci9m6hb/w530-h640/IMG_20210721_184346.jpg" style ="height:1000px; width:1000px" >

    </center>  


 </body>

</html>


OUTPUT:

Pune

Landmarks:

Baramati

Daund

supe


Slip 3

<!--

Write a program using html with following CSS specifications- [15]

i. The background colour of the company name should be in green.

ii. The text colour of the company name should be red.

iii. The heading should be large –with font ''comic sans ms''

iv. The description of the company should be displayed in blue color in a paragraph


-->




<!DOCTYPE html>

 <html>

  <head>

<style>

  h1 { 

       color: red;

       background-color: green;

   font-size: 100px;

   font-family:comic sans ms;

  }

  

  p   {

      color: blue;

  }

  

    </style>

  </head>

 

  <body bgcolor="pink">

  

     <h1> Learnwithnil </h1> 

 

     <p> Yes u can do it </p> 

     

 </body>

</html>



OUTPUT:

Learnwithnil

Yes u can do it



Slip 4




Item_Table.html


<html>

 <body bgcolor = "navyblue">

   <table border = "2">  

    <center>

     <tr>

          <th rowspan="2"> Item No </th> <th rowspan="2"> Item Name </th> <th> Price  </th>  

 </tr>

 <tr>

<td> Rs. </td> <td> Paise </td>

 </tr>

 

  <tr>

<td> 1 </td> <td> Programming in Python </td> <td> 500 </td> <td> 50 </td>

 </tr>

 

   <tr>

<td> 1 </td> <td> Programming in Java </td> <td> 1000 </td> <td> 500 </td>

 </tr>

    

    </center>

   </table>

  </form>

 </body>

</html>


OUTPUT

Item NoItem NamePrice
Rs.Paise
1Programming in Python50050
1Programming in Java1000500




Slip 5



Slip 6


Slip 7

Design HTML 5 Page Using CSS Which Displays the following Navigation Bar



<!DOCTYPE html>

<html>

<head>

<style>

ul {

  list-style-type: none;

  margin: 0;

  padding: 0px;

  overflow: hidden;

  background-color: lightgray;

}


li {

  float: left;

}


li a {

  display: block;

  color: blue;

 font-size:20px;

  text-align: center;

  padding: 10px 20px;

  text-decoration: none;

}

.active{

background-color: gray;

color: white;

}

li a:hover {

  background-color: orange;

  color: white;

}

</style>

</head>

<body>


<ul>

  <li><a class="active" href="https://learnwithnil.blogspot.com/">Home</a></li>

  <li><a href="https://learnwithnil.blogspot.com/">Java</a></li>

  <li><a href="https://learnwithnil.blogspot.com/">HTML</a></li>

  <li><a href="https://learnwithnil.blogspot.com/">CSS</a></li>

</ul>


</body>

</html>


 

OUTPUT


Slip 8


) Design an HTML form to accept two strings from the user. Write a PHP script for the following. a. Find whether the small string appears at the start of the large string. b. Find the position of the small string in the big string. c. Compare both the string for first n characters, also the comparison should not be case sensitive.


Stringls.html


<!DOCTYPE html>

 <html>

  <head> <title> myString </title> </head>

  

  <body bgcolor = "navyblue">

  <form action="Stringls.php" method = "POST">

  <label for = "l1"> Enter the Large String :</label>

  <input type = "text" name = "lstring" id = "l1">  <br><br>

  

  <label for = "l2"> Enter the small String :</label>

  <input type = "text" name = "sstring" id = "l2">   <br><br>

  

  <label for = "l3"> Enter the length of String :</label>

  <input type = "text" name = "length" id = "l3">  <br><br>

  

 

  <input type = "submit" value = "submit">

  <input type = "reset"  value = "reset">

  

  </body>

  </html>

   


OUTPUT


 

 

 

 



Stringls.php


<?php


$ls = $_POST['lstring'];

$ss = $_POST['sstring'];

$len = $_POST['length'];


echo "<BR>The large string is: $ls";

echo "<BR>The small string is: $ss";

echo "<BR>The length of string is: $len";


$pos = strpos($ls,$ss);

   if($pos === 0)

echo "<BR>Yes small string present at the biggining of the large string...";

   else

  echo "<BR>No.. small string can't present at the biggining of the large string...";

  

  echo "<BR> position of small string in the large string: $pos";

  

  $compare = strncasecmp($ls, $ss, 5);

  if($compare == 0)

  echo "<BR> Both string are equal";

  else if($compare < 0)

      echo "String 1 is small than String 2";

  else

  echo "String 1 is large than string 2";

?>


OUTPUT

The large string is: learnwithnil
The small string is: learn
The length of string is: 5
Yes small string present at the biggining of the large string...
position of small string in the large string: 0
Both string are equal


Slip 9 


Selector.html

<!DOCTYPE html>
 <html>
  <head> <title> myString </title> </head>
  
  <body bgcolor = "navyblue">
  <form action="Selector.php" method = "POST">
  <label for = "l1"> Enter the String :</label>
  <input type = "text" name = "string" id = "l1">  <br><br>
  
  <select name = "select">
  <option> ,
  <option > %
  <option > #
  <option selected> $
  </select>
   <br> <br>  

  <input type = "submit" value = "submit">
  <input type = "reset"  value = "reset">
  
  </body>
  </html>


OUTPUT:
 



 


Selector.php

<?php

$str = $_POST['string'];
$separator = $_POST['select'];

echo "<BR> String is : $str";
echo "<BR> Selector is : $separator <BR>";

echo "<BR> Split the string into separate words using the given separator :<BR>";
$ans = explode($separator,$str);
foreach ($ans as $words )
  {
echo $words;
echo "<BR>";
  }
  echo "<BR>Replace all the occurrences of separator in the given string with some other separator:<BR>";
  echo str_replace(',', '$', $str);
  
  echo "<BR>  Find the last word in the given string(Use strrstr() function): <BR>";
  echo strrstr($str, "nil",false);
?>
    



OUTPUT
String is : learn, with, nil, is, the, best, of, the, world
Selector is : ,

Split the string into separate words using the given separator :
learn
with
nil
is
the
best
of
the
world

Replace all the occurrences of separator in the given string with some other separator:
learn$ with$ nil$ is$ the$ best$ of$ the$ world
Find the last word in the given string(Use strrstr() function):


Slip 10

Write a script to accept two integers(Use html form having 2 textboxes). Write a PHP script to, a. Find mod of the two numbers. b. Find the power of first number raised to the second. c. Find the sum of first n numbers (considering first number as n) d. Find the factorial of second number. (Write separate function for each of the above operations.)




Slip 11

Slip 12

slip12.html

<!--

Write a PHP script for the following: Design a form to accept two numbers from the user. 

Give options to choose the arithmetic operation (use radio buttons). Display the result on the next 

form. (Use the concept of function and default parameters. Use ‘include’ construct or require 

statement)


-->



<!DOCTYPE html>

 <html>

  <head>

<title> Myform</title>

  </head>

 

  <body bgcolor="navyblue">

   <form action = "slip12.php" method = "POST" >

     <center>

  

  <label for="no1"> Plz Enter the 1st number: </label>

  <input type = "text" name = "no1" id = "no1">    <BR>

  

  <label for="no2"> Plz Enter the 2nd number: </label>

  <input type = "text" name = "no2" id = "no2">    <BR>

  

  <h3> Choose any one: <h3>

  <input type = "radio" name = "math" id = "sum" value ="sum">  Addition  <BR>

     <input type = "radio" name = "math" id = "sub" value ="sub">  Substract   <BR>

  <input type = "radio" name = "math" id = "mul" value ="mul">  Multiplication   <BR>

   <input type = "radio" name = "math" id = "div" value ="div">  Division   <BR>

   

   

  <input type="submit" value = "submit" >

  <input type = "reset" value = "reset">

  

</center>

 </form>

</body>

</html>

html OUTPUT:



Choose any one:

 Addition
 Substract
 Multiplication
 Division
 



slip12.php

<?php


$num1 = $_POST['no1'];

$num2 = $_POST['no2'];


$Selected_option = $_POST['math'];


 function addition($num1 , $num2)

 {

return $num1 + $num2 ;

 }


 function substraction($num1 , $num2)

 {

return $num1 - $num2 ;

 }

 

 function multiplication($num1 , $num2)

 {

return $num1 * $num2 ;

 }

 

 function division($num1 , $num2)

 {

return $num1 / $num2 ;

 }


if($Selected_option == "sum")

     echo "<BR>The Addition of two numbers are:".addition($num1,$num2);

 

if($Selected_option == "sub")

     echo "<BR>The Substraction of two numbers are:".substraction($num1,$num2);

 

if($Selected_option == "mul")

     echo "<BR>The Multiplication of two numbers are:".multiplication($num1,$num2);

 

if($Selected_option == "div")

     echo "<BR>The Division of two numbers are:".division($num1,$num2);

 

?>

PHP OUTPUT:


The Addition of two numbers are:60






Slip 13 


 Write a PHP script to create a chess board using CSS on table cells.


<!DOCTYPE html>

 <html>

   

  <body>

   <table width = "300px" border = "1px" cellspacing ="0px">

    <?php

     

  $value =0;

  for($col=0; $col<8; $col++)

  {

  echo "<tr>";

        $value = $col;

   

  for($row=0; $row<8; $row++)

  {

  if($value%2 == 0)

  {

  echo "<td height=40px width = 20px bgcolor = black> </td>";

  $value++;

  }

  else

  {

  echo "<td height = 40px width = 20px bgcolor = white > </td>";

  $value++;

  }

              }

      echo "</tr>";

      }

    ?>

</table>

   </body>

 </html>   

 

              html OUTPUT:





Slip 14


Slip 15


slip15.html


<!-- 
Design a form to accept string from the user and perform the following operations
a. To select first 5 words from the string
b. Convert the given string to lowercase and then to Title case.
c. Pad the given string with “*” from left and right both the sides. 
d. Remove the leading whitespaces from the given string. 
e. Find the reverse of given string.

--->


<!DOCTYPE html>
 <html>
  <head>
<title> Myform</title>
  </head>
 
  <body bgcolor="pink">
    <form action = "slip15.php" method = "POST">
     <center> 
<label for = "string" > Enter the string:</label>
  <input type = "text" name = "string" id="string"> <BR>
  
  <input type="submit" value = "submit" color="red" >
  <input type = "reset" value = "reset">

 
 
    </center>  
   </form>
 </body>
</html>

html OUTPUT:


 
 


slip15.php


<?php

$str = $_POST['string'];

$impld = implode(' ',array_slice(explode(' ',$str),0,5));
echo "<BR>Select first 5 words from the string:<BR>";
print_r($impld);
echo "<BR>";

echo "<BR>b. Convert the given string to lowercase :<BR>";
$expld = explode(' ',$str); 
for($i=0; $i<5;$i++)
  {
    echo strtolower($expld[$i]);
echo"<BR>";
  }
echo "<BR>Convert the given string to Title case:<BR>";
for($i=0; $i<5;$i++)
  {
    echo ucwords(strtolower($expld[$i]));
echo"<BR>";
  }
  
  echo "<BR> Pad the given string with “*” from left and right both the sides:<BR>";
  echo str_pad($str,70,'*',STR_PAD_BOTH);
  
  echo "<BR><BR>Remove the leading whitespaces from the given string :<BR>";
  echo trim($str,' ');
  
  echo "<BR><BR>Find the reverse of given string:<BR>";
  echo strrev($str);
  
?>

PHP OUTPUT:

Select first 5 words from the string:
learn with nil is the

b. Convert the given string to lowercase :
learn
with
nil
is
the

Convert the given string to Title case:
Learn
With
Nil
Is
The

Pad the given string with “*” from left and right both the sides:
***************learn with nil is the best of the world****************

Remove the leading whitespaces from the given string :
learn with nil is the best of the world

Find the reverse of given string:
dlrow eht fo tseb eht si lin htiw nrael

Slip 16 


slip16.html


<!--
Write a PHP script for the following: Design a form to accept the marks of 5 different 
subjects of a student, having serial number, subject name & marks out of 100. Display the 
result in the tabular format which will have total, percentage and grade. Use only 3 text 
boxes.(Use array of form parameters)
-->


<!DOCTYPE html>
 <html>
  <head>
<title> Myform</title>
  </head>
 
  <body bgcolor="pink">
    <form action = "slip16.php" method = "POST">
     <center> 
<label for = "s1" > Enter the serial no:</label>
  <input type = "text" name = "s1" id="s1" placeholder = "1,2,3,4,5"> <BR>
<label for = "s2" > Enter the subject name:</label>
  <input type = "text" name = "s2" id="s2" placeholder = "math,stat,geo,eng,cs"> <BR>
<label for = "s3" > Enter the marks:</label>
  <input type = "text" name = "s3" id="s3" placeholder = "50,66,76,46,88"> <BR>
  
  <input type="submit" value = "submit" color="red" >
  <input type = "reset" value = "reset">

 
 
    </center>  
   </form>
 </body>
</html>

html OUTPUT:


 
 
 
 


slip16.php

<?php

$serialno = $_POST['s1'];
$subjectname = $_POST['s2'];
$marks = $_POST['s3'];

$ex_sno = explode(',',$serialno);
$ex_sname = explode(',',$subjectname);
$ex_marks = explode(',',$marks);

$totalmarks= 0;
for($i=0; $i<5; $i++)
    $totalmarks = $totalmarks + $ex_marks[$i];

$percentage = ($totalmarks/500)*100;

echo "<table align = center border = 3>";

echo "<tr>
        <th> Serial no </th>
<th> Subject Name </th>
<th> Marks </th>
  </tr> ";
  
 for($i=0; $i<5; $i++)
 {
  echo "<tr> 
           <td> $ex_sno[$i] </td>
   <td> $ex_sname[$i] </td>
   <td> $ex_marks[$i] </td>
</tr> ";
 }
 
 echo "<tr>
          <th colspan =2> Total marks: </th> 
          <td> $totalmarks </td> 
       </tr> ";
   
 echo "<tr>
          <th colspan =2> Percentage: </th> 
          <td> $percentage </td> 
       </tr> ";
   
 echo "</table>";
 
 ?>

 

PHP OUTPUT:
Serial noSubject NameMarks
1math77
2stat88
3geo99
4sc66
5ds90
Total marks:420
Percentage:84



Slip 17


Write a PHP script to sort the following associative array : 

array(“Sagar"=>"31","Vicky"=>"41","Leena"=>"39","Ramesh"=>"40") in

a) ascending order sort by Value

b) ascending order sort by Key

c) descending order sorting by Value

d) descending order sorting by Key 



<?php


$arr = array("Sagar"=>"31","Vicky"=>"41","Leena"=>"39","Ramesh"=>"40");

  echo "<BR> Original Array:<BR>";

  print_r($arr);


asort($arr);

echo "<BR><BR> Ascending order sort by Value:<BR>";

print_r($arr);  


ksort($arr);

echo "<BR><BR> Ascending order sort by key:<BR>";

print_r($arr);  


rsort($arr);

echo "<BR><BR> Descensing order sort by Value:<BR>";

print_r($arr);  


krsort($arr);

echo "<BR><BR> Descensing order sort by Key:<BR>";

print_r($arr);  


?>

PHP OUTPUT:
Original Array:
Array ( [Sagar] => 31 [Vicky] => 41 [Leena] => 39 [Ramesh] => 40 )

Ascending order sort by Value:
Array ( [Sagar] => 31 [Leena] => 39 [Ramesh] => 40 [Vicky] => 41 )

Ascending order sort by key:
Array ( [Leena] => 39 [Ramesh] => 40 [Sagar] => 31 [Vicky] => 41 )

Descensing order sort by Value:
Array ( [0] => 41 [1] => 40 [2] => 39 [3] => 31 )

Descensing order sort by Key:
Array ( [3] => 31 [2] => 39 [1] => 40 [0] => 41 )


Slip 18


 Write a menu driven program to perform the following operations on an associative array

a. Reverse the order of each element’s key-value pair.

b. Traverse the element in an array in random order.

c. Convert the array elements into individual variables.

d. Display the elements of an array along with key. 


Slip18.html


<html>

 <body bgcolor = "navyblue">

  <form action="slip18.php" method="POST">

  

   <center>

    <h2> Enter ur choice: <h2>

    <h3><input type="radio" name="option" value="1">Reverse the order of each elements key-value pair</h3>

    <h3><input type="radio" name="option" value="2">Traverse the elements in array in random order</h3>

<h3><input type="radio" name="option" value="3">Convert the array elements into individual variables.</h3>

<h3><input type="radio" name="option" value="4">Display the elements of an array along with key.</h3>



    <input type="submit" value="Submit">

   </center>

  

  </form>

 </body>

</html>

html OUTPUT:


Enter ur choice:

Reverse the order of each elements key-value pair

Traverse the elements in array in random order

Convert the array elements into individual variables.

Display the elements of an array along with key.


slip18.php

<?php

$op = $_POST['option'];

$input = array("Sonny"=>"50", "Tonny"=>"80", "Money"=>"58");

switch($op)

{

case 1 :  $flipped = array_flip($input);

       print_r($flipped);

       break;

case 2 : 

      print_r(array_rand($input));

          break;

case 3 : 

 $arr = extract($input);

                             echo "<BR> \$Sonny = ".$Sonny ;

 echo "<BR> \$Tonny = $Tonny ";

 echo "<BR> \$Money = $Money ";

          break;

case 4 : 

         foreach($input as $k=>$v)

     echo "<BR>$k";

          break;

}


?>


PHP OUTPUT:


Array ( [50] => Sonny [80] => Tonny [58] => Money )




Slip 19


Write a PHP script to accept 2 strings from the user, the first string should be a sentence and 

second can be a word. 

a. Delete a small part from first string after accepting position and number of characters to 

remove. 

b. Insert the given small string in the given big string at specified position without removing 

any characters from the big string. 

c. Replace some characters/ words from given big string with the given small string at 

specified position.


Slip19.html

<!DOCTYPE html>

 <html>

 <head> <title> form </title> </head>

 <body bgcolor = "navyblue">

  <form action = "slip19.php" method = "POST">

     <center>

  <label for = "sen"> Plz Enter the Senternce: </label>

  <input type = "text" name ="sen" id = "sen">    <BR>

  <label for = "word"> Plz Enter the word: </label>

  <input type = "text" name ="word" id = "word"> <BR>

  

  

    <input type="submit" value="Submit">

    <input type="reset" value="reset">


   </center>

  

  </form>

 </body>

</html>


html OUTPUT:



 


Slip19.php


<?php

$sentence = $_POST['sen'];

$smallword = $_POST['word'];

echo "<BR>original String :".$sentence;

$rem = str_replace($smallword," ",$sentence);

echo "<BR>After removing specific word : $rem";

$replace = substr_replace($sentence,$smallword,3,0);

echo "<BR>After Inserting Specific word in Sentence: $replace";

$rep = str_replace($smallword,"bottom",$sentence);

echo "<BR>After Replacing specific word : $rep";

?>

PHP OUTPUT:

original String :I'm the top of the world
After removing specific word : I'm the of the world
After Inserting Specific word in Sentence: I'mtop the top of the world
After Replacing specific word : I'm the bottom of the world

  


Slip 20


Write a menu driven program to perform the following operations on associative arrays: 

a) Split an array into chunks 

b) Sort the array by values without changing the keys. 

c) Filter the even elements from an array. 



Slip20.html

<html>

 <body bgcolor = "navyblue">

  <form action="slip20.php" method="POST">

  

   <center>

    <h2> Enter ur choice: <h2>

    <h3><input type="radio" name="option" value="1">Split an array into chunks </h3>

    <h3><input type="radio" name="option" value="2">Sort the array by values without changing the keys. </h3>

<h3><input type="radio" name="option" value="3">Filter the even elements from an array. </h3>

 


    <input type="submit" value="Submit">

   </center>

  

  </form>

 </body>

</html>


html OUTPUT:

Enter ur choice:

Split an array into chunks

Sort the array by values without changing the keys.

Filter the even elements from an array.



Slip20.php


<?php

$val = $_POST['option'];

$input = array("Sonny"=>"50", "Tonny"=>"80", "Money"=>"58","laila"=>"99","nihan"=>"90","kemal"=>"88");

function evenCmp($input)

{

return !($input & 1);

}

switch($val)

{

case 1 :  $split = array_chunk($input,2);

       print_r($split);

       break;

case 2 : 

 asort($input);

      print_r($input);

          break;

case 3 : 

         print_r(array_filter($input,"evenCmp"));

          break;

}


?>


PHP OUTPUT:

Array ( [0] => Array ( [0] => 50 [1] => 80 ) [1] => Array ( [0] => 58 [1] => 99 ) [2] => Array ( [0] => 90 [1] => 88 ) )


Slip 21


 Create an array of 15 high temperatures, approximating the weather for a spring month, 

 then find the average high temp, the five warmest high temps Display the result on the browser


Slip21.php

<?php


$temp = array(35,37,36,35,33,36,37,38,39,40,41,37,40,32,33);

$total = 0;

foreach( $temp as $ele)

{

  $total += $ele;

 }

 $avg = $total/count($temp);

 

 echo "<BR> The Average of high temperature is :".$avg;

 rsort($temp);

 

 echo "<BR> The five warmest high  temperature is:";

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

  {

    echo "<BR> $temp[$i] ";

  }


?>


 PHP OUTPUT:


The Average of high temperature is :36.6
The five warmest high temperature is:
41
40
40
39
38


Slip 22


Write a menu driven program to perform the following queue related operations 

a) Insert an element in queue 

b) Delete an element from queue 

c) Display the contents of queue


Slip22.html

<!DOCTYPE html>

 <html>

  <head>

<title> Myform</title>

  </head>

 

  <body bgcolor="navyblue">

   <form action = "slip22.php" method = "POST" >

     <center>

   Select ur choice:<BR>

  <label for="queue">  Insert an element in queue </label>

  <input type = "radio" name = "queue" value = "enqueue" id = "enqueue">    <BR>

      <label for = "name"> Enter the element to add in queue: </label>

        <input type = "text" name ="str" id = "name">  <BR>

  

      <label for = "queue"> Delete an element from queue  </label>

  <input type ="radio" name = "queue" value = "dequeue" id = "dequeue" > <br>


      <label for = "display"> Display the contents of queue </label>

  <input type ="radio" name = "queue" value = "display" id = "display" > <br>


  <input type="submit" value = "submit" >

  <input type = "reset" value = "reset">

  

 </center>

 </form>

</body>

</html>

html OUTPUT:


Select ur choice:




 

Slip22.php

<?php


$value = $_POST['queue'];


$string = $_POST['str'];


 $queue = array("pink","yellow","red");



 if($value == "enqueue")

 {

    array_unshift($queue,$string);

echo "Successfully enqueue element";

echo "<BR>";

    print_r($queue);


 }

 if($value == "dequeue")

 {

    array_shift($queue);

echo "Successfully dequeue element";

echo "<BR>";

print_r($queue);


 }

 

 if($value == "display")

 {

 echo "<BR>";

 print_r($queue);

 }

 

?>

PHP OUTPUT:

Successfully enqueue element
Array ( [0] => green [1] => pink [2] => yellow [3] => red )


Slip 23

Write a menu driven program to perform the following stack related operations: 

a) Insert an element in stack

 b) Delete an element from stack 

 c) Display the contents of stack


Slip23.html


<!DOCTYPE html>

 <html>

  <head>

<title> Myform</title>

  </head>

 

  <body bgcolor="navyblue">

   <form action = "slip23.php" method = "POST" >

     <center>

   Select ur choice:<BR>

  <label for="push">  Insert an element in stack </label>

  <input type = "radio" name = "stack" value = "push" id = "push">    <BR>

      <label for = "name"> Enter the push element: </label>

        <input type = "text" name ="str" id = "name">  <BR>

  

      <label for = "pop"> Delete an element from stack  </label>

  <input type ="radio" name = "stack" value = "pop" id = "pop" > <br>


      <label for = "display"> Display the contents of stack </label>

  <input type ="radio" name = "stack" value = "display" id = "display" > <br>


  <input type="submit" value = "submit" >

  <input type = "reset" value = "reset">

  

 </center>

 </form>

</body>

</html>


html OUTPUT:

Select ur choice:




 


Slip23.php


<?php


$value = $_POST['stack'];


$string = $_POST['str'];


 $stack = array("pink","yellow","red");


 if($value == "push")

 {

    array_push($stack,$string);

echo "Successfully push element";

echo "<BR>";

    print_r($stack);


 }

 if($value == "pop")

 {

    array_pop($stack);

echo "Successfully pop element";

echo "<BR>";

print_r($stack);


 }

 

 if($value == "display")

 {

 echo "<BR>";

 print_r($stack);

 }

 

?>

PHP OUTPUT:
Successfully push element
Array ( [0] => pink [1] => yellow [2] => red [3] => green )


Slip 24


 Write a PHP program to read two file names from user and append content of first file into second file


firsttext.txt:

hello good morning everyone..

I'm the top of the world..

12345

secondtext.txt:

 nothing in file


Slip24.html


<!DOCTYPE html>

 <html>

 <head> <title> form </title> </head>

 <body bgcolor = "navyblue">

  <form action = "slip24.php" method = "POST">

     <center>

  <label for = "first"> Plz Enter the first file name: </label>

  <input type = "text" name ="first" id = "first">    <BR>

  <label for = "second"> Plz Enter the second file name: </label>

  <input type = "text" name ="second" id = "second"> <BR>

  

  

    <input type="submit" value="Submit">

    <input type="reset" value="reset">


   </center>

  

  </form>

 </body>

</html>

html OUTPUT:



 




Slip24.php


  <?php


$f1 = $_POST['first'];

$f2 = $_POST['second'];


$file1 = fopen($f1,"r") or die("<BR> 1st file not exist");


$file2 = fopen($f2,"a") or die("<BR>2nd file not exist");

   

$data = fread($file1,filesize($f1));

 

 echo "<BR> first file data:<BR>";

print_r($data);


fwrite($file2,$data);

echo "<BR> Successfully write data into second file";


fclose($file1);

fclose($file2);

?>


firsttext.txt:

hello good morning everyone..

I'm the top of the world..

12345

secondtext.txt:

hello good morning everyone..

I'm the top of the world..

12345


PHP OUTPUT:

first file data:
hello good morning everyone.. I'm the top of the world.. 12345
Successfully write data into second file



Slip 25


Write a menu driven program to perform various file operations. Accept filename from 

user. 

a) Display type of file. 

b) Display last modification time of file 

c) Display the size of file 

d) Delete the file



Slip25.html



<!DOCTYPE html>

 <html>

 <head> <title> form </title> </head>

 <body bgcolor = "navyblue">

  <form action = "slip25.php" method = "POST">

     <center>

  <label for = "file"> Plz Enter the file name: </label>

  <input type = "text" name ="file" id = "file">    <BR>      

  

    <input type="submit" value="Submit">

    <input type="reset" value="reset">


   </center>

  

  </form>

 </body>

</html>


html OUTPUT:


 


Slip25.php


<?php


$f = $_POST['file'];


echo "<BR> Type of the file is :".filetype($f);


echo "<BR> Last Modification time of file is :".filemtime($f);


echo "<BR> File size is ".filesize($f);


echo "<BR> now file is deleted".unlink($f);


?>


fileoperation.txt

learn with nil 

i wanna ruin our friendship

12345

  

PHP OUTPUT:


Type of the file is :file
Last Modification time of file is :1672329371
File size is 51
now file is deleted1


Slip 26


Slip 27


Write a PHP program to read two file names from user and copy the content of first file into 
second file

copyfile1.txt:

hello good morning everyone..
I'm the top of the world..
12345

copyfile2.txt:
 Null file

Slip27.html


<!DOCTYPE html>
 <html>
 <head> <title> form </title> </head>
 <body bgcolor = "navyblue">
  <form action = "slip27.php" method = "POST">
     <center>
  <label for = "first"> Plz Enter the first file name: </label>
  <input type = "text" name ="first" id = "first">    <BR>
  <label for = "second"> Plz Enter the second file name: </label>
  <input type = "text" name ="second" id = "second"> <BR>
  
  
    <input type="submit" value="Submit">
    <input type="reset" value="reset">

   </center>
  
  </form>
 </body>
</html>

html OUTPUT:



 

  

Slip27.php

<?php

$f1 = $_POST['first'];
$f2 = $_POST['second'];

$ok = copy($f1,$f2);
if($ok)
    echo "<BR>successfulyy content copy from first to second file ";
else
    echo "<BR>something problem to copy content";


?>

copyfile1.txt:

hello good morning everyone..
I'm the top of the world..
12345

copyfile2.txt:
hello good morning everyone..
I'm the top of the world..
12345

PHP OUTPUT:

successfulyy content copy from first to second file


Slip 28


Write a program to read a flat file “student.dat”, calculate the percentage and display the 

data from file in tabular format.(Student.dat file contains rollno, name, OS, WT, DS, Python,

Java, CN )



Slip28.html


<!DOCTYPE html>

 <html>

 <head> <title> form </title> </head>

 <body bgcolor = "navyblue">

  <form action = "slip28.php" method = "POST">

     <center>

  <label for = "fname"> Plz Enter the file name: </label>

  <input type = "text" name ="fname" id = "fname">    <BR>

 

    <input type="submit" value="Submit">

    <input type="reset" value="reset">


   </center>

  

  </form>

 </body>

</html>

html OUTPUT:


 

  

Slip28.php


<?php 


$file=$_POST['fname'];


if(file_exists($file))


{


$fp=fopen($file,"r");


echo "<br><br>";


echo "<table border=2 align=center>";


echo "<tr><th>Roll No</th>";


echo "<th>Name</th>";


echo "<th>Syspo</th>";


echo "<th>TCS</th>";


echo "<th>CN</th>";


echo "<th>PHP</th>";


echo "<th>JAVA</th>";


echo "<th>BA</th>";


echo "<th>Percentage</th></tr><br>";


while(!feof($fp))


{


$d=fgets($fp);


$s=explode(' ',$d);


if(!empty($s[0]) && !empty($s[1]) && !empty($s[2]) && !empty($s[3]) && !empty($s[4])                     && !empty($s[5])&& !empty($s[6])&& !empty($s[7]))


{


$m=array($s[2],$s[3],$s[4],$s[5],$s[6],$s[7]);


$total=array_sum($m);


$per=$total/6;


echo "<tr><td>$s[0]</td>";


echo "<td>$s[1]</td>";


echo "<td>$s[2]</td>";


echo "<td>$s[3]</td>";


echo "<td>$s[4]</td>";


echo "<td>$s[5]</td>";


echo "<td>$s[6]</td>";


echo "<td>$s[7]</td>";


echo "<th>$per</th></tr><br>";

}


}


}


?>

student.dat:

1 kemal 88 78 76 96 85 78 


2 nihan 68 95 32 56 89 54 


3 snehal 69 78 45 45 41 55


PHP OUTPUT:




Roll NoNameSyspoTCSCNPHPJAVABAPercentage
1kemal88787696857883.5
2nihan68953256895465.666666666667
3snehal69784545415555.5


Slip 29


Consider the following entities and their relationships [15]

Event (eno , title , date ) 

Committee ( cno , name, head , from_time ,to_time , status) 

Event and Committee have many to many relationship. Write a php script to accept title of event 

and modify status committee as working.




Slip29.html

<!DOCTYPE html>

 <html>

  <head> <title> mysql Event </title> </head>

  

  <body bgcolor="navyblue">

   <form action = "slip29.php" method = "POST">

   <label for="ename">Enter the name of Event: </label>

   <input type = "text" name = "ename" id = "ename"> <BR>


   <input type = "submit" value = "submit">

   <input type = "reset" value = "reset">


   </form>

  </body>

 </html>  


html OUTPUT:


 


Slip29.php

<?php


$name = $_POST['ename'];


$connect = mysqli_connect("localhost","root","","swapnildb");

if($connect)

echo "Successfully connect<BR>";

else

echo "Doesn't connnect";


$query = "update event,committee,event_committee set status = 'wedding' where title = '$name' and event.eno = event_committee.eno and committee.cno = event_committee.cno ";


if($query)

echo "Successfully Modify";

else

echo "Problem in Modify";



$result = mysqli_query($connect, $query);


if($result)

echo "<BR>ok";

else

echo "not ok";


?>


PHP OUTPUT:
Successfully connect
Successfully Modify
ok


Slip 30


Consider the following entities and their relationships [15]

Student (Stud_id,name,class) 

Competition (c_no,c_name,type) 

Relationship between student and competition is many-many with attribute rank and year. Create 

a RDB in 3NF for the above and solve the following. Using above database write a script in PHP 

to accept a competition name from user and display information of student who has secured 1st 

rank in that competition.


Slip30.html

<!DOCTYPE html>

<html>

<body bgcolor ="pink">

<form action="slip30.php"method="get" >

<center>

            <label for = "cname">Enter Competition Name :</label>

            <input type="text" name="cname" id ="cname">  <br><br>



<input type="submit" value="Submit">

<input type="reset" value="reset">


</center>

</form>

</body>

</html>


html OUTPUT:

 

 


Slip30.php

<?php

        $cnames=$_GET['cname'];

                       

                        $hn="localhost";

                        $un="root";

                        $pass="";

                        $db="swapnildb";

                       

                        $link=mysqli_connect($hn,$un,$pass,$db);

            if(!$link)

            {

                        die('Connection Failed:'.mysqli_error());

            }

            //$sql="SELECT * FROM student WHERE CNo IN (SELECT CNo FROM competition WHERE CName = '".$cname."')";

            $sql="select * from student,competition,studcomp where student.Sid=studcomp.Sid and competition.CNo=studcomp.CNo and rank='1' and CName='".$cnames."'";

            $res=mysqli_query($link,$sql);          

                       

            if(mysqli_num_rows($res)>0)

            {

                        while($row=mysqli_fetch_assoc($res))

         {

                                    echo"Stud No : ".$row['Sid']."<br>"."  Name  : ".$row['SName']."<br>";

                                    echo"Class :  ".$row['SClass']."<br>";

                                    echo"--------------------------"."<br>";

                        }

            }

            else

            {

                        echo"error";

            }

            mysqli_close($link);


?>


PHP OUTPUT:









Q1. Design a HTML form to accept a string. Write a PHP script for the following.

a)  Write a function to count the total number of Vowels from the script.

  b)Show the occurrences of each Vowel from the script.


Accept_Str.html


<!DOCTYPE html>

 <html>

  <head> <title> Accept String </title> </head>

  

  <body bgcolor ="navyblue">

   <form action = "Accept_Str.php" method = "POST">

   <label for = "str" > Enter the String: </label>

   <input type = "text" name = "str" id = "str" > <BR>

   

   <input type = "submit" value = "submit">

   <input type = "reset" value = "reset" >

   

   </form>

  </body>

 </html>

html OUTPUT:




Accept_Str.php


<?php


$string = $_POST['str'];


$vowels = array("a"=>0,"e"=>0,"i"=>0,"o"=>0,"u"=>0);


function ChkVowels($string)

{

$vowels = array("a"=>0,"e"=>0,"i"=>0,"o"=>0,"u"=>0);

    $cnt = 0;

 for($i=0; $i<strlen($string); $i++)

{

  if(strtolower($string[$i]) == 'a')

{

        ++$cnt;

++$vowels['a'];

}

if(strtolower($string[$i]) == 'e') 

{

++$cnt;

++$vowels['e'];

}

if(strtolower($string[$i]) == 'i') 

{

++$cnt;

++$vowels['i'];

}

if(strtolower($string[$i]) == 'o') 

{

++$cnt;

++$vowels['o'];

}

if(strtolower($string[$i]) == 'u') 

{

++$cnt;

++$vowels['u'];

}

}



echo "<h1>Total number of vowels found : ".$cnt."<h1>";


echo "Occurence of 'a' : ".$vowels['a']."<br>";

echo "Occurence of 'e' : ".$vowels['e']."<br>";

echo "Occurence of 'i' : ".$vowels['i']."<br>";

echo "Occurence of 'o' : ".$vowels['o']."<br>";

echo "Occurence of 'u' : ".$vowels['u']."<br>";


}

 

  ChkVowels($string);


?>




Q1. Write a menu driven program the following operation on an associative array                 

a)    Reverse the order of each element’s key-value pair.

b)   Traverse the element in an array in random order.


Asso_Array.html

<!-- 

Q1. Write a menu driven program the following operation on an associative array

a) Reverse the order of each element’s key-value pair.

b) Traverse the element in an array in random order.

-->

<html>

 <body bgcolor = "navyblue">

  <form action="Asso_Array.php" method="POST">

  

   <center>

    <h2> Enter ur choice: <h2>

    <h3><input type="radio" name="option" value="1">Reverse the order of each elements key-value pair</h3>

    <h3><input type="radio" name="option" value="2">Traverse the elements in array in random order</h3>

    <input type="submit" value="Submit">

   </center>

  

  </form>

 </body>

</html>


html OUTPUT:




Asso_Array.php


<?php

$op = $_POST['option'];

$input = array("Sonny"=>"50", "Tonny"=>"80", "Money"=>"58");

switch($op)

{

case 1 :  $flipped = array_flip($input);

       print_r($flipped);

       break;

case 2 : 

      print_r(array_rand($input));

          break;

}


?>



Q Design a form to accept a string and check whether the given string is Palindrome or not.

 

Palindrome.html


<html>

 <body bgcolor = "navyblue">

  <form action="Palindrome.php" method="POST">

  

   <center>

    <h2> Enter  String: <h2>

    <h3><input type="text" name="string" > </h3>

    <input type="submit" value="Submit">

<input type="reset" value="reset">

   </center>

  

  </form>

 </body>

</html>

html OUTPUT:




Palindrome.php


<?php


$str = $_POST['string'];


echo "Ur enter String: $str";


$rev = strrev($str);


 for($i=0;$i<strlen($str);$i++)

 {

if($str[$i] == $rev[$i])

   $flag = 'yes';

else

$flag = 'no';

 }

  if($flag == 'yes')

  echo"<BR> The String = $str  is palindrome";

  else

    echo"<BR> The String = $str is not palindrome";



?>


Q. Create a HTML document to display the following screen





 State_List.html


 <!DOCTYPE html>

 <html>

   

  <body bgcolor = "pink">

  

   <h2> List of Indian States with their Capitals: </h2>

      <ol> 

        <li> Delhi  </li>

       <ul type = "circle" > 

    <li> NewDelhi </li>

</ul> 

 

        <li> Haryana  </li>

       <ul type = "circle" > 

    <li> Chandigarh </li>

</ul> 

  

        <li> Gujarat  </li>

       <ul type = "circle" > 

    <li> Gandhinager </li>

</ul> 

 

  <li> Rajasthan  </li>

       <ul type = "circle" > 

    <li> Jaipur </li>

</ul> 

 

  <li> Maharashtra  </li>

       <ul type = "circle" > 

    <li> Mumbai </li>

</ul> 

 

  <li> Uttarpradesh  </li>

       <ul type = "circle" > 

    <li> Lucknow </li>

</ul> 

  </ol>

  

   

   </body>

   </html>

html OUTPUT:




Q. Create a HTML form that accept user email. Write a PHP program to check whether user email address contain @ symbol or not. Display proper message.



Email.html


<html>

 <body bgcolor = "navyblue">

  <form action="Email.php" method="POST">

  

   <center>

    <h2> Enter  Email: <h2>

    <h3><input type="text" name="email" > </h3>

    <input type="submit" value="Submit">

<input type="reset" value="reset">

   </center>

  

  </form>

 </body>

</html>

html OUTPUT:




Email.php


<?php


$str = $_POST['email'];


echo "Ur enter Email: $str";


  $e=explode('@',$str);

      if (count($e)>=2)

           echo "<br>Email id contains @ symbol ";

   else   

   echo "<br>email id does not contains  @ symbol";



?>








Q. Write a HTML code, which generate the following output

                                                   

 

Item No

 

Item Name

           

Price

 

 Rs.

 Paise    

1

Programming in Python

500

     50

2

Programming in Java

345

     00

 

 

 

 

 






Item_Table.html


<html>

 <body bgcolor = "navyblue">

   <table border = "2">  

    <center>

     <tr>

          <th rowspan="2"> Item No </th> <th rowspan="2"> Item Name </th> <th> Price  </th>  

 </tr>

 <tr>

<td> Rs. </td> <td> Paise </td>

 </tr>

 

  <tr>

<td> 1 </td> <td> Programming in Python </td> <td> 500 </td> <td> 50 </td>

 </tr>

 

   <tr>

<td> 1 </td> <td> Programming in Java </td> <td> 1000 </td> <td> 500 </td>

 </tr>

    

    </center>

   </table>

  </form>

 </body>

</html>


html OUTPUT:




Q. Write the HTML code for generating the form as shown below.

Apply the internal CSS to following form change the font size of the heading to 6pt and change the color to red and also change the background color yellow                   





<!DOCTYPE html>

 <html>

  <head>

<title> Myform</title>

<style>

h1{

    font-size = 30px;

}

h1{

    color : red;

}

body{

     background-color : yellow;

}

</style>

  </head>

 

  <body >

   <form>


  <h1> Operating Sytem information </h1>

  <label for="name"> Enter ur name : </label>

  <input type ="text" name = "name" id = "name" > <br>


      <label for = "Pass"> Password : </label>

      <input type = "password" name=Pass id = Pass > <br>


  <h1> Which of the following  operating system you used: </h1> <br>

  

  <input type="checkbox" name="check1" id = "check1"> 

  <label for = "check1"> Window </label> <br>

  <input type="checkbox" name="check2" id = "check2"> 

  <label for = "check2"> Linux </label> <br>

  <input type="checkbox" name="check3" id = "check3"> 

  <label for = "check3"> Ubantu </label> <br>

 

  <h1> Which of the following  operating system you like: </h1>  <br>

  

  <input type="radio" id="one" name="one" >

  <label for="one"> Window </label><br>

  <input type="radio" id="two" name="two" >

  <label for="two"> Linux </label><br>  

  <input type="radio" id="three" name="three" >

  <label for="three"> Ubantu </label><br><br>


  You have to complete the form 

  <button type="button" > sign up  </button>


 </form>

</body>

</html>


html OUTPUT:






Q. Write a menu driven program to perform the following stack and queue related               

 operations:                   [Hint: use array_push(), array_pop()]

 

a) Insert an element in stack

b) Delete an element from stack

c) Display the contents of stack 


Array_PushPop.html                                 


<!DOCTYPE html>

 <html>

  <head>

<title> Myform</title>

  </head>

 

  <body bgcolor="navyblue">

   <form action = "Array_PushPop.php" method = "POST" >

     <center>

   Select ur choice:<BR>

  <label for="push">  Insert an element in stack </label>

  <input type = "radio" name = "stack" value = "push" id = "push">    <BR>

      <label for = "name"> Enter the push element: </label>

        <input type = "text" name ="str" id = "name">  <BR>

  

      <label for = "pop"> Delete an element from stack  </label>

  <input type ="radio" name = "stack" value = "pop" id = "pop" > <br>


      <label for = "display"> Display the contents of stack </label>

  <input type ="radio" name = "stack" value = "display" id = "display" > <br>


  <input type="submit" value = "submit" >

  <input type = "reset" value = "reset">

  

</center>

 </form>

</body>

</html>

html OUTPUT:




Array_PushPop.php                               



<?php


$value = $_POST['stack'];


$string = $_POST['str'];


 $stack = array("pink","yellow","red");




 if($value == "push")

 {

    array_push($stack,$string);

echo "Successfully push element";

echo "<BR>";

    print_r($stack);


 }

 if($value == "pop")

 {

    array_pop($stack);

echo "Successfully php element";

echo "<BR>";

print_r($stack);


 }

 

 if($value == "display")

 {

echo "<BR>";

print_r($stack);

 }

 

?>


OR


PushPop.php



<?php

$stack=array("red");

print_r($stack);

echo "<BR>";


array_push($stack,"pink");

print_r($stack);

echo "<BR>";


array_push($stack,"navyblue","white","blue","yellow");

print_r($stack);

echo "<BR>";


array_pop($stack);

print_r($stack);

echo "<BR>";


array_pop($stack);

print_r($stack);

echo "<BR>";

array_pop($stack);

print_r($stack);

echo "<BR>";array_pop($stack);

print_r($stack);

echo "<BR>";

?>



Write a menu driven program to perform the following operation on an associative array.

a)    Display the elements of an array along with key.

Display the size of an array.



Asso_ArrayKey.html


<!DOCTYPE html>

 <html>

  <head>

<title> Myform</title>

  </head>

 

  <body bgcolor="navyblue">

   <form action = "Asso_ArrayKey.php" method = "POST" >

     <center>

   Select ur choice:<BR>

  <label for="key">  Display the elements of an array along with key. </label>

  <input type = "radio" name = "ass" value = "key" id = "key">    <BR>

      

  

      <label for = "size"> Display the size of an array. </label>

  <input type ="radio" name = "ass" value = "size" id = "size" > <br>


    


  <input type="submit" value = "submit" >

  <input type = "reset" value = "reset">

  

</center>

 </form>

</body>

</html>

html OUTPUT:





Asso_ArrayKey.php 



<?php


 //  Q1. Write a menu driven program to perform the following operation on an associative array. [15 marks]

 //   a) Display the elements of an array along with key.

 //   b) Display the size of an array.

 

 $array_key = $_POST['ass'];

 $array_size = $_POST['ass'];

 

$array = array("swapnil"=>"90","raj"=>"50", "vrushi"=>"80");


if($array_key == "key")

{

foreach($array as $x=>$val)

{

echo "<BR>key:".$x;

}

}


if($array_key == "size")

{

echo "<BR> The size of Assosiative array is:".count($array);

}



?>



Q.Write a PHP script that inserts a new item in an array at any position.

      (hint : use array_splice())                 


Array_Splice.php


<?php 


// Q1. Write a PHP script that inserts a new item in an array at any position. 

//      (hint : use array_splice())


 $array1 = array("swapnil"=>"90","raj"=>"50", "vrushi"=>"80","sonny"=>"55","John"=>"99");

 print_r($array1);

 

echo"<BR><BR>";


 $array2 = array("mangu"=>"35", "kedar"=>"40");


 array_splice($array1,3,2,$array2);

 

 print_r($array1);



?>




Q. Write a script to accept two integers(Use html form having 2 textboxes).             

     Write a PHP script to  find mod of the two numbers                  



 Integer_Mod.html                                                                                                                                                             


<!--


Q1. Write a script to accept two integers(Use html form having 2 textboxes).

     Write a PHP script to  find mod of the two numbers

-->


<!DOCTYPE html>

 <html>

  <head>

<title> Myform</title>

  </head>

 

  <body bgcolor="navyblue">

   <form action = "Integer_Mod.php" method = "POST" >

     <center>

  

  <label for="int1">  Enter the 1st integer: </label>

  <input type = "text" name = "int1" id = "int1">    <BR>

        

      <label for = "int2"> Enter the 2nd interger: </label>

  <input type ="text" name = "int2" id = "int2" > <br>


  <input type="submit" value = "submit" >

  <input type = "reset" value = "reset">

  

</center>

 </form>

</body>

</html>


html OUTPUT:



 Integer_Mod.php                                                                                                                                                         



<?php


$num1 = $_POST['int1'];

$num2 = $_POST['int2'];


$mod = $num1 % $num2;

 echo "The mod of integer1 and intger2 is:".$mod;


?>




Q.  Write a PHP script for the following: Design a form to accept a string.                         

 Write a function to find the length of given string without using built in functions



String_Length.html

<!--

.  Write a PHP script for the following: Design a form to accept a string.        [15 marks]

 Write a function to find the length of given string without using built in functions


-->


<!DOCTYPE html>

 <html>

  <head>

<title> Myform</title>

  </head>

 

  <body bgcolor="navyblue">

   <form action = "String_Length.php" method = "POST" >

     <center>

  

  <label for="name">  Enter the String: </label>

  <input type = "text" name = "str" id = "name">    <BR>

  


  <input type="submit" value = "submit" >

  <input type = "reset" value = "reset">

  

</center>

 </form>

</body>

</html>


html OUTPUT:




String_Length.php

<?php


$string = $_POST['str'];


echo "given string is :".$string;

$i = 0;

$count = 0;

  while($string[$i] != '')

  {

  $count++;

  }

  echo "The Length of string without using built in funcion :".$count;


?>


Q.  Write a PHP script for the following: Design a form to accept a string.                           

    Convert the given string to lowercase and then to Title case



String_LowerCase.html


<!--

    Write a PHP script for the following: Design a form to accept a string.     

     Convert the given string to lowercase and then to Title case

-->


<!DOCTYPE html>

 <html>

  <head>

<title> Myform</title>

  </head>

 

  <body bgcolor="navyblue">

   <form action = "String_LowerCase.php" method = "POST" >

     <center>

  

  <label for="name">  Enter the String: </label>

  <input type = "text" name = "str" id = "name">    <BR>

  


  <input type="submit" value = "submit" >

  <input type = "reset" value = "reset">

  

</center>

 </form>

</body>

</html>


html OUTPUT:



String_LowerCase.php


<?php


$string = $_POST['str'];


echo "given string is :".$string;


 echo "<BR>The lowercase string is: ".strtolower($string);

 

  echo "<BR>The Title case string is: ".ucwords(strtolower($string));



?>






a

Comments

Popular posts from this blog

Practical slips programs : Machine Learning

Full Stack Developement Practical Slips Programs

MCS Advanced Database & Web Technology