O'Reilly logo

Core PHP Programming, Third Edition by Leon Atkinson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required