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">

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']; ?>.


  • 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


Adriana said…
thanks for share!
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.
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.
Darilha said…
i love your post, thank you for sharing.
Eunice said…
you inspire me, thanks.
Ediane said…
in some point i disagree with you, but still your words seen very coherent to me.
I would like to thnkx for the efforts you've put in writing this web site. I am hoping the same high-grade website post from you in the upcoming as well. Actually your creative writing skills has inspired me to get my own website now. Actually the blogging is spreading its wings fast. Your write up is a great example of it.
Backlinks said…
I seldom comment, but i did some searching and wound up here 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!

Popular posts from this blog

Tic Tac Toe - Using App Inventor Beta

Solved: Ionic ENOENT Invalid device state error when using sudo on Mac

Xamarin Forms vs React Native