PHP Lesson 2 - Processing Forms

In this lesson you will learn how to use PHP for processing a form that could be used in real-life scenarios.



Create a Form

  1. Open the index.php file that you created in lesson 1.

  2. Erase everything.

  3. Copy and paste the following into your file and save it.


<form action="form_process.php" method="post">
<input type="text" name="FirstName">
<input type="submit" value="Submit">
<form>

Create a Page to Process the Form

  1. In the same folder as the index.php file, create a new file called form_process.php.

  2. Type the following into the new file and save it.


Your first name is <?php echo $_POST['FirstName']; ?>.

Lesson

  • Because you typed method="post" in the tag on the first page, whatever you type in and send for the FirstName field gets stored in the php array called $_POST.

  • If you type method="get" in the form tag, then the field values will be put into the php variable called $_GET.

  • If on the form_process page you don't care whether the field values come through the $_GET or $_POST arrays then you can access them through the php array called $_REQUEST. For example: $_REQUEST['FirstName']. The $_REQUEST array contains any URL parameters, any Form parameters, and any Cookie variables.


Lesson Index

Comments

sem calcinha said…
Adoro me mostrar peladinha na web cam
Alena said…
you have such a good sense when you're writing, please keep doing the good work.http://www.queroouvirmusica.com
Hi. I read a few of your other posts and i wanted to say thank you for the informative posts.
Brígida said…
i will get in touch with this post and site as well , giving this kind of post is really happy. looking for someone here. anyway waiting for another post here.http://www.bobesponjajogos.org
Darilha said…
i love your post, thank you for sharing.http://www.musicaparabaixar.net
Eunice said…
you inspire me, thanks.http://www.jogosdahotwheels.com
Ediane said…
in some point i disagree with you, but still your words seen very coherent to me.http://www.jogosdogta.net
Backlinks said…
I seldom comment, but i did some searching and wound up here 2717Sus.com: 2717 Susquehanna Rd., Roslyn, PA 19001. And I actually do have a couple of questions for you if it's allright. Is it simply me or does it give the impression like a few of the comments look like written by brain dead folks? And, if you are posting at additional sites, I'd like to keep up with anything fresh you have to post. Could you make a list of the complete urls of all your shared sites like your linkedin profile, Facebook page or twitter feed?
Dagmar said…
thanks a lot for enjoying this beauty article with me. i am appreciating it very much!http://www.musicaparabaixar.net

Popular posts from this blog

Adobe® Flex® Combobox: Selecting an Item Without Using SelectedIndex

Parameters Sent by TinyWebDB in App Inventor for Android