Flipping Forms
Posted on 12. Mar, 2010 by admin in Basics
For this series of tutorials I said you needed to know HTML. Since I am a nice guy I will teach you the limited HTML we need to know for our next two tutorials. Let’s start with a basic HTML document and then go from there.
<html> <head> <title>Flipping Forms Tutorial</title> </head> <body> The following is a form: </body> </html>
In previous tutorials we have manually entered our integers and strings. For this we needed access to our PHP file to change the values. This would not be particularly helpful to a typical user on your website. HTML forms allow us to submit values to PHP which we can process. Let’s make a simple form
<html> <head> <title>Flipping Forms Tutorial</title> </head> <body> The following is a form: <form action="index.php"> What is your favorite book?: <input type="text" name="book" /> What is your favorite movie?: <input type="text" name="movie" /> What is your favorite website?: <input type="text" name="website" /> <input type="submit" /> </form> </body> </html>
Let’s go through the HTML one part at a time. If you are already well versed in HTML you should be able to skip this tutorial, and move on to the next one on POST.
Action=”index.php” – This line is the document that you are directed to after you hit the submit button. I am assuming you are still using index.php to run your PHP code .If you are not, you will have to modify it to the one you are using. You can direct it to a completely different one to run your PHP code there as well (more in the next tutorial).
<input type=”text” name=”book” /> – In this line we have the textbox type which is text for textbox. We also have a name which is very important. Follow the same rules as the PHP variable names to keep everything simple. We will use this name to access it in PHP so keep it simple and short.
<input type=”submit” /> – Our submit button. You can also add value=”Your Text”, to change the text from “Submit Query”.
Now that you have a little more knowledge with PHP forms, we can move on to more fun things!

