Handling an HTML Form

Now that I have an HTML form, I’ll write a bare-bones PHP script to handle it. When I say that this script will be handing the form, I mean that it will do something with the data it receives (which, normally but not always, the user entered). In this chapter, the scripts will reiterate the data back to the Web browser, but in later examples, it will be stored in a MySQL database, checked against previously stored values, sent in emails, and more.

The beauty of PHP—and what makes it so easy to learn and use—is how well it interacts with HTML forms. If you have a text box in your HTML form whose name attribute is email, then PHP will store the text entered there in a variable called $email.

Rather than requiring a parsing ...

Get PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.