Call us Toll-Free:
1-800-218-1525
Live ChatEmail us

 Sponsors

Simple form submission with PHP

Code Wizard, 12-30-2006

This is a script that demonstrates simple form handling in PHP. The script prints a form to the browser that submits to itself. The script checks to see that the "posted" variable was set by the form (meaning the form has been submitted), processes the form information, and prints out a message indicating that the submission was successful.

<?php

if($_POST['posted'] == "1") { // checks to see if $_POST['posted'] was set (i.e. the form was submitted)
// process the information...
// ...
// ...
echo "Your form was posted and processed!";
} else { // the user has not submitted the form -- show the form

?>


<form action="<?=$_SERVER['REQUEST_URI']?>" method="post">
<input type="hidden" name="posted" value="1">
... ...
<input type="submit" value="go">
</form>

<?
}
?>
Enjoyed this post?

Subscribe Now to receive new posts via Email as soon as they come out.

 Comments
Post your comments












Note: No link spamming! If your message contains link/s, it will NOT be published on the site before manually approved by one of our moderators.



About Us  |  Contact us  |  Privacy Policy  |  Terms & Conditions