180. PHP Program to store student details using functions.
How does this program work?
- In this program you are going to learn about how to store student details using functions in PHP.
- By using functions we can read the student details and print it.
Here is the code
<html>
<head>
<title>PHP Program To store student details using functions</title>
</head>
<body>
<form method="post">
<table border="0">
<tr>
<td> <input type="text" name="num1" value="" placeholder="Enter your name"/> </td>
</tr>
<tr>
<td> <input type="text" name="num2" value="" placeholder="Enter Rollno"/> </td>
</tr>
<tr>
<td> <input type="text" name="num3" value="" placeholder="Enter Percentage"/> </td>
</tr>
<tr>
<td> <input type="submit" name="submit" value="Submit"/> </td>
</tr>
</table>
</form>
<?php
function student($name, $rollno, $per)
{
echo "Your name is: ".$name."</br>";
echo "Rollno : ".$rollno."</br>";
echo "Percentage% : ".$per."</br>";
}
if(isset($_POST['submit'])) {
echo "Student Details:</br>";
$n1 = $_POST['num1'];
$r1 = $_POST['num2'];
$p1 = $_POST['num3'];
student($n1, $r1, $p1);
}
?>
</body>
</html>