PHP FORM HANDLING

Example:

– an HTML form with more than one input fields and a submit button.

<html>
<body>
<form action=”jgl.php” method=”post”>
Name: <input type=”text” name=”fname”/>
Age: <input type=”text” name=”age”/>
Emailadress: <input type=”text” name=”emailad”/>
cellnumber: <input type=”text” name=”cell”/>
<input type=”submit”/>
</form>
</body>
</html>

When a user fills out the form above and click on the submit button, the form data is sent to a php file, called “jgl.php”:

“jgl.php” code looks like this:

<html>
<body>

Welcome <?php echo $_POST[“fname”];?>!<br/>
You are <?php echo $_POST[“age”];?> years old.<br/>
Your emailaddress is <?php echo $_POST[“emailad”];?>.<br/>
Your contact number is <?php echo $_POST[“cell”];?>.<br/>

</body>
</html>

Output:

Welcome user!
You are 20 years old.
Your emailaddress is user123@yahoo.com
Your contact number is 123-456-78