Working with forms in PHP - Text Boxes
(Page 3 of 7 )
Now, we will add another element to our form - a textbox. In form.html, after the line:
<FORM method="POST" action="form.php"> |
add the line:
Fill in the text box: <INPUT type="text" name="mytextbox" size="20"><BR> |
This will add a text box called "mytextbox" that is 20 characters long to our simple form. Now, let's do something with the data that is entered in the textbox in out form.php script. After this line in form.php:
echo "Great! You clicked the button!\n"; |
add this line:
echo "<BR>You typed <b>" . $_POST['mytextbox'] . "</b> in the textbox.\n"; |
Now, go ahead and try it out again. As you can see, we have passed the data in the textbox from the first page to the next. It really is that simple. This is basically how it is going to work for each of the other form elements. There are a few subtle differences, but we will go through those.
Next: Checkboxes >>
More Miscellaneous Articles
More By Matt Wade
|
| · | | | · | | | · | | | · | | | · | | | · | | | · | | | · | | | · | | | · | | | · | | | · | | | · | | | · | | | · | | | · | | | | |
|