1.8. Receiving User Input

Manipulating variables that you set within your script is somewhat interesting, but hardly anything to rave about. Scripts become much more useful when they use input from the user. When you call PHP from an HTML form, the form fields are turned into variables. Listing 1.9 is a form that calls Listing 1.10, a further modification of our example script.

Listing 1.9. HTML form for lunch information
 <html> <head> <title>Listing 1-9</title> </head> <body> <form action="1-10.php" method="post"> Your name: <input type="text" name="YourName"><br> Cost of a lunch: <input type="text" name="CostOfLunch"><br> Days buying lunch: <input type="text" name="DaysBuyingLunch"><br> <input type="submit" value="Compute"> </form> </body> ...

Get Core PHP Programming, 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.