Program using HTML and PHP to design form to take input such as Name of student, Class, Division, Marks in English, Hindi, Science, Mathematics, and EVS. Calculate Total and Percentage scored by student along with “Congratulations” message if the student pass


 First Create A Form Which Will Help To Enter Data according to the question

(congratulations.html)

<!DOCTYPE html>

<html>

<body bgcolor="cyan">

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

<h1>Welcome students</h1>

Enter your name:<input type="text" name="n1"><br>

Enter Your Class:<input type="text" name="n2"><br>

Enter Your Division:<input type="text" name="n3"><br>

<h1>Input your Marks below</h1>

English:<input type="number" name="m1"><br>

Hindi:<input type="number" name="m2"><br>

Science:<input type="number" name="m3"><br>

Mathematics:<input type="number" name="m4"><br>

EVS:<input type="number" name="m5"><br>

Enter OutofMarks:<input type="number" name="m6"><br>

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

</form>

</html>


Output


Now Embed The Php File Into the form  Tag

(per.php)

<html>

<body bgcolor="orange">

<?php

$name=$_POST["n1"];

$cls=$_POST["n2"];

$div=$_POST["n3"];

$eng=$_POST["m1"];

$hin=$_POST["m2"];

$sci=$_POST["m3"];

$math=$_POST["m4"];

$evs=$_POST["m5"];

$outof=$_POST["m6"];

echo "<h3>Hello $name<h3>","<br>";

echo "<h3>Your Class is $cls and Div is $div<h3>","<br>";

$total=$eng+$hin+$sci+$math+$evs;


$per=$total*100/$outof;


echo "<h3>Your Details</h3>";

echo "<table border=2 bgcolor=cyan>

      <tr>

      <th>Name</th>

      <th>Class</th>

      <th>Div</th>

      </tr>.

       <tr>

      <th>$name</th>

     <th>$cls</th>

     <th>$div</th>

     </tr>

       </table>";   

echo "<br> ";

echo "<h3>Your Marks are as follows</h3>";

echo "<table border=2 bgcolor=cyan>

     <tr>

      <th>English</th>

      <th>Hindi</th>

      <th>Science</th>

<th>Maths</th>

<th>Evs</th>

<th>Total Marks</th>

<th>OutofMarks</th>

</tr>

      

       <tr>

      <th>$eng</th>

     <th>$hin</th>

     <th>$sci</th>

      <th>$math</th>

      <th>$evs</th>

     <th>$total</th>

      <th>$outof</th>

 </tr>

</table>";

echo "<h3>Total Marks is $total</h3>","<br>";

if($per>35){

echo "<h1>Congratulations</h1>";

echo "<h3>Percentage is $per</h3>","<br>";

}

else {

echo "<h1>Sorry You have Failed</h1>";

echo "<h3>Percentage is $per</h3>","<br>";

}

?>


Output






      


Comments