Slip 21 - C) Write a PHP script to create a form to accept student information (name, class, address). Once the student information is accepted, accept marks in next form (Phy, Bio, Chem, Maths, Marathi, English).Display the mark sheet for the student in the next form containing name, class, marks of the subject, total and percentage.

Solution:

cookies.html


<html>

<head><title>COOKIES PROGRAM</title></head>

<body>

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

Enter name<input type="text"name="name" value=""><br>

Enter  class<input type="text"name="class" value=""><br>

Enter  address<input type="text"name="address" value=""><br>

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

</form>

</body>

</html>


form2.php


<?php
$name=$_POST['name'];
$class=$_POST['class'];
$address=$_POST['address'];
setcookie("name","$name",time()+3660);
setcookie("class","$class",time()+3600);
setcookie("address","$address",time()+3600);
?>
<html>
<body>
<head><title>ACCEPT THE MARKS OF SUBJECT</title></head>
<form action="form3.php" method="post">
Enter MARKS OF PHYSICS<input type="text"name="phy" value=""><br>
Enter  MARKS OF CHEM<input type="text"name="chem" value=""><br>
Enter  MARKS OF BIOLOGY<input type="text"name="bio" value=""><br>
Enter MARKS OF MATHS<input type="text"name="maths" value=""><br>
Enter  MARKS OF MARATHI<input type="text"name="marathi" value=""><br>
Enter  MARKS OF ENGLISH<input type="text"name="eng" value=""><br>
<input type="submit"name="submit" value="submit">
</form>
</body>
</html>


form3.php


<?php
$x=$_COOKIE['name'];
$y=$_COOKIE['class'];
$z=$_COOKIE['address'];
$bio=$_POST['bio'];
$chem=$_POST['chem'];
$maths=$_POST['maths'];
$mara=$_POST['marathi'];
$eng=$_POST['eng'];
$phy=$_POST['phy'];
$total=$chem+$bio+$phy+$maths+$mara+$eng;
$per=$total/6.0;
?>
<html>
<table border="2">
<tr>
<th colspan="2">MARKSHEET</th>
</tr>
<tr>
<td colspan="2"><b>NAME:</b><?php echo "$x"?><br>
<b>CLASS:</b><?php echo "$y"?><br>
<b>ADDRESS:</b><?php echo "$z"?><br>
</tr>
<tr>
<td colspan="2">PHYSICS
<td><?php echo "$phy"?></td>
</tr>
<tr>
<td colspan="2">CHEMISTRY
<td><?php echo "$chem"?></td>
</tr>
<tr>
<td colspan="2">BIOLOGY
<td><?php echo "$bio"?></td>
</tr>
<tr>
<td colspan="2">MATHS
<td><?php echo "$maths"?></td>
</tr>
<tr>
<td colspan="2">MARATHI
<td><?php echo "$mara"?></td>
</tr>
<tr>
<td colspan="2">ENGLISH
<td><?php echo "$eng"?></td>
</tr>
<tr>
<td colspan="2">TOTAL
<td><?php echo "$total"?></td>
</tr>
<tr>
<td colspan="2">PERCENTAGE
<td><?php echo "$per"?></td>
</tr>
</table>
</html>

Post a Comment

0 Comments