This is a discussion on Form Examples in PHP within the PHP Programming forums, part of the Web Development category; Form Examples in PHP <HTML> <BODY> <FORM METHOD="POST" ACTION="getformvalue.php&...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| Form Examples in PHP <HTML> <BODY> <FORM METHOD="POST" ACTION="getformvalue.php"> <H2>Contact List</H2> <BR>Name: <BR><INPUT TYPE="TEXT" NAME="Nickname"> <BR> <BR>Address: <BR><INPUT TYPE="TEXT" NAME="Fullname"> <BR> <BR>ContactNo: <BR><TEXTAREA NAME="Memo" ROWS="4" COLS="40" WRAP="PHYSICAL"> </TEXTAREA> <BR> <BR> <INPUT TYPE="SUBMIT"> </FORM> </BODY> <!-- getformvalue.php <?php echo "<BR>Nickname=$Name"; echo "<BR>Fullname=$Address"; echo "<BR>Memo=$ContactNo"; ?> |
| Sponsored Links |
| |||
| Form Checkbox <html> <head> <title>Checkbox Demo</title> </head> <body> <h1>Checkbox Demo</h1> <h3>Demonstrates checkboxes</h3> <form action ="HandleFormCheckBox.php"> <ul> <li><input type ="checkbox" name ="chkFries" value ="11.00">Fries</li> <li><input type ="checkbox" name ="chkSoda" value ="12.85">Soda</li> <li><input type ="checkbox" name ="chkShake" value ="1.30">Shake</li> <li><input type ="checkbox" name ="chkKetchup" value =".05">Ketchup</li> </ul> <input type ="submit"> </form> </body> </html> <!-- HandleFormCheckBox.php <html> <head> <title>Checkbox Demo</title> </head> <body> <h3>Demonstrates reading checkboxes</h3> <? print <<<HERE chkFries: $chkFries <br> chkSoda: $chkSoda <br> chkShake: $chkShake <br> chkKetchup: $chkKetchup <br> <hr> HERE; $total = 0; if (!empty($chkFries)){ print ("You chose Fries <br>"); $total = $total + $chkFries; } if (!empty($chkSoda)){ print ("You chose Soda <br>"); $total = $total + $chkSoda; } if (!empty($chkShake)){ print ("You chose Shake <br>"); $total = $total + $chkShake; } if (!empty($chkKetchup)){ print ("You chose Ketchup <br>"); $total = $total + $chkKetchup; } print "The total cost is \$$total"; ?> </body> </html> --> |
| |||
| Form Email <html> <head> <title>Simple Send Mail Form</title> </head> <body> <h1>Mail Form</h1> <form name="form1" method="post" action="SimpleEmail.php"> <table> <tr><td><b>To</b></td><td><input type="text" name="mailto" size="35"></td></tr> <tr><td><b>Subject</b></td> <td><input type="text" name="mailsubject" size="35"></td></tr> <tr><td><b>Message</b></td> <td><textarea name="mailbody" cols="50" rows="7"></textarea></td> </tr> <tr><td colspan="2"> <input type="submit" name="Submit" value="Send"> </td> </tr> </table> </form> </body> </html> <!-- SimpleEmail.php <?php if (empty ($mailto) ) { die ( "Recipient is blank! ") ; } if (empty ($mailsubject) ){ $mailsubject=" " ; } if (empty ($mailbody) ) { $mailbody=" " ; } $result = mail ($mailto, $mailsubject, $mailbody) ; if ($result) { echo "Email sent successfully!" ; }else{ echo "Email could not be sent." ; } ?> --> |
| |||
| Form Data - Dealing with Array Data <HTML> <BODY> <FORM METHOD="POST" ACTION="DealWithArrayFormData.php"> <H1>Contact Information</H1> <TABLE> <TR> <TD>Childrens' Names:</TD> </TR> <TR> <TD><INPUT TYPE="TEXT" NAME="children[]"></TD> </TR> <TR> <TD><INPUT TYPE="TEXT" NAME="children[]"></TD> </TR> <TR> <TD><INPUT TYPE="TEXT" NAME="children[]"></TD> </TR> <TR> <TD><INPUT TYPE="TEXT" NAME="children[]"></TD> </TR> <TR> <TD><INPUT TYPE="TEXT" NAME="children[]"></TD> </TR> </TABLE> <BR> <BR> <BR> <INPUT TYPE="SUBMIT" VALUE="Submit"> <BR> <BR> <INPUT TYPE="RESET" VALUE="Clear the Form"> </FORM> </BODY> </HTML> <!-- DealWithArrayFormData.php <?php foreach ($children as $index => $child){ echo "<BR>child[$index]=$child"; } echo "<BR>"; sort($children); foreach ($children as $index => $child){ echo "<BR>child[$index]=$child"; } ?> --> |
| |||
| Radio buttons examples It is used to select anyone of the input from several inputs. That is selection of one from many choices. Code: <HTML>
<HEAD>
<TITLE>Candy preference form</TITLE>
</HEAD>
<BODY>
<FORM ACTION="SelectFormControlHandler.php" METHOD="POST">
What's your most favorite kind of candy?<BR>
<INPUT TYPE="radio" NAME="Candy" VALUE="peanut butter cups">Peanut butter cups<BR>
<INPUT TYPE="radio" NAME="Candy" VALUE="Snickers">Snickers<BR>
<INPUT TYPE="radio" NAME="Candy" VALUE="Turtles">Turtles<BR>
<INPUT TYPE="submit">
</FORM>
</BODY>
</HTML>
<!-- SelectFormControlHandler.php
<HTML>
<HEAD>
<TITLE>Candy preference reply</TITLE>
</HEAD>
<BODY>
Yum, <?php print("$Candy! ");
if($Candy == "peanut butter cups"){
print("peanut butter cups");
print(" $Candy.");
}else{
print("$Candy");
if($Candy == "Snickers"){
print("Snickers");
}elseif($Candy == "Turtles"){
print("Turtles");
}
}
?>
</BODY>
</HTML>
--> |
| |||
| Form Select - Select button examples Code: <html>
<head>
<title>An HTML form including a SELECT element</title>
</head>
<body>
<form action="formSelectData.php" method="POST">
<input type="text" name="user">
<br>
<textarea name="address" rows="5" cols="40"></textarea>
<br>
<select name="products[]" multiple>
<option>option1
<option>option2
<option>option3
<option>option4
</select>
<br>
<input type="submit" value="OK">
</form>
</body>
</html>
<!-- formSelectData.php
<html>
<head>
<title>Reading input from the form</title>
</head>
<body>
<?php
print "Welcome <b>$user</b><p>\n\n";
print "Your address is:<p>\n\n<b>$address</b><p>\n\n";
print "Your product choices are:<p>\n\n";
print "<ul>\n\n";
foreach ( $products as $value ){
print "<li>$value<br>\n";
}
print "</ul>";
?>
</body>
</html>
--> |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| PHP with Mysql examples | varghese | PHP Programming | 2 | 11-19-2007 07:13 AM |
| PHP functions and examples | varghese | PHP Programming | 7 | 11-19-2007 07:02 AM |
| Create a php function examples | varghese | PHP Programming | 0 | 11-19-2007 07:00 AM |
| HTML and CSS examples | varghese | HTML, CSS and Javascript Coding Techniques | 0 | 11-09-2007 04:33 AM |
| Examples in SQL/MYSQL | varghese | Database Support | 0 | 11-09-2007 04:10 AM |