Previous --> Page 2 |This is Page 3 | Next --> Page 4

Using PHP to Dynamically Power our Pages

Let's start by creating a form that gets some information from a person.

View the source of this page and copy the code for the form (and its table.) into an HTML file called "phpDynamic.php"

Name
Gender Female Male
Favorite Color

We need to create a page that will use the information entered by the user. To do this, let's create a page called "phpProcessPage.php"

In the "action" attribute of the form tag, add the process page. Make sure you include the method="POST" in the form tag.

SO HOW IS THIS GOING TO WORK?

When you hit "Submit" on a form, it POSTS each field's (text, radio, menu, etc.) value to a PHP variable identified as follows:
$_POST['nameOfField']

For example, if you have a field called "Name" on a form, when you hit submit, the variable $_POST['Name'] will have the value that was entered by the user.

By writing

<?php echo $_POST['Name']; ?>

in a file, it will print the value entered by the user.

To give more clarity to what is being printed, you could write

...
<BODY>
The name you entered: <?php echo $_POST['Name']; ?>
</BODY>
...

Note that if you want to include additional text when you print a posted variable, you must do so with the following syntax:

<BODY>
All data on separate lines: <?php echo "{$_POST['Name']}<br>{$_POST['Age']}";
</BODY>

ASSIGNMENT 3 - Name your files php3.php & php3process.php

Create a form that asks the user to fill out six different questions. Use a variety of text fields, textboxes, radio buttons, and drop-down menus. Have the ACTION of the form set equal to the process page.
Then create the process page and have it print out all the information that was entered by the user on the first page. Use the POST method for the form attribute.