PHP Day 9: Using PHP with HTML Forms

Last night I made my first functional HTML form using PHP! It’s very basic, but it works! :D This five-minute video shows what I learned — not much, but enough to get started.

Links for PHP Day 9: Using PHP with HTML Forms

PHP superglobals:

Making the HTML form functional:

  • Remember to use the $_POST superglobal when using method="post" in your form, and the $_GET superglobal when using method="get" in your form.
  • The value you pick for the name attribute for the inputs in your HTML form will be the key for the superglobal array, as in $_POST['inputname'].
  • Note: in the video, I didn’t put quotes around the key (I wrote $_POST[firstname] instead of $_POST['firstname']), which is bad practice. Oops!

Next up, PHP security issues. Hurray!

Posted on February 13th, 2007 | Leave a comment | Trackback URL

1 Comment

  1. Ultra Lean Green

    July 31st, 2008

    I like the videos when you are in them! :)

    So I made a form, but when I click the back button all the data is gone.

    Do you know how we can make the form sticky so that if i hit submit & then hit the back button the data will still be their or if I use a multi step form I can go back to change the data.

Share Your Thoughts