A Script to Acquire User Input

For now, we’ll keep our HTML separate from our PHP code. Listing 10.2 builds a simple HTML form.

Listing 10.2. A Simple HTML Form
 1: <!DOCTYPE html PUBLIC
 2:     "-//W3C//DTD XHTML 1.0 Strict//EN"
 3:     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 4: <html>
 5: <head>
 6: <title>Listing 10.2 A Simple HTML Form</title>
 7: </head>
 8: <body>
 9: <div>
10: <form action="listing10.3.php" method="get">
11: <p><input type="text" name="user"/></p>
12: <p>
13: <textarea name="address" rows="5" cols="40">
14: </textarea>
15: </p>
16: <p><input type="submit" value="hit it!" /></p>
17: </form>
18: </div>
19: </body>
20: </html>>

We define a form that contains a text field with the name "user" on line 11, a text area with ...

Get Sams Teach Yourself PHP in 24 Hours, Third Edition 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.