HTML Form using PHP

To create a HTML form using php create a file with name "form.php" and paste the following code in it :

<html>
<body>
<form action="print.php" method="get">
Name:<input type="text" name="Name" value"Jim"/><br />
Password:<input type="password" name="Password" maxlength="10"/><br />
Age: <select name="Age">
<option value="15-25">15-25</option>
<option value="25-30">25-30</option>
<option value="30-40">30-40</option>
<option value="40-55">40-55</option>
</select><br /><br />
Favourite Activities :<br />
<textarea name="Story" rows="15" cols=50">
Enter your favourite activities here...</textarea><br /><br />
What is your favorite sport ?<br />
<input type="radio" name="Favesport" value="Cricket"/>Cricket
<input type="radio" name="Favesport" value="Football"/>Football
<input type="radio" name="Favesport" value="Tennis"/>Tennis
<input type="radio" name="Favesport" value="Baseball"/>Baseball
<input type="radio" name="Favesport" value="Basketball"/>Basketball
<br /><br />
What is your favourite programming language ?<br />
<input type="radio" name="Languages" value="Java"/>Java
<input type="radio" name="Languages" value="PHP"/>PHP
<input type="radio" name="Languages" value="HTML"/>HTML
<input type="radio" name="Languages" value="Python"/>Python
<input type="radio" name="Languages" value="C++"/>C++
<br /><br />
Enter your profession :<br />
<textarea name="Profession" rows="2" cols=30">
Enter your profession..</textarea><br /><br />
Enter your mail-id :<br />
<textarea name="mail" rows="2" cols=30">
</textarea><br /><br />
<br /><br />
<input type="submit" />
</form>
</body>
</html>




Create a file "print.php" and paste the following code in it :

<?php
print "Name : {$_GET['Name']}<br /><br />";
print "Password : {$_GET['Password']}<br /><br />";
print "Age : {$_GET['Age']}<br /><br />";
print "Activities : {$_GET['Story']}<br /><br />";
print "Favorite Sport : {$_GET['Favesport']}<br /><br />";
print "Favorite Programming Language : {$_GET['Languages']}<br /><br />";
print "Profession : {$_GET['Profession']}<br /><br />";
print "E-mail ID  : {$_GET['mail']}<br /><br />";
?>  

The data entered in the form will be printed through "print.php" where the data inputs are generated using "$_GET".

Top