Sending Values to a Script Manually

In the examples so far, all of the data received in the handle_form.php script came from what the user entered in the form. There are, however, two different ways you can pass a PHP script variables and values, both worth knowing.

The first method is to make use of HTML’s hidden input type:

<input type="hidden" name="name" value="Brian" />

As long as this code is anywhere between the form tags, the variable $name will have a value of Brian in the handling PHP script.

The second method is to append a value to the handling PHP script’s URL:

www.dmcinsights.com/page.php?name=Brian

This technique emulates the get method of an HTML form and can be used in lieu of or as well as an HTML form.

To manually send ...

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.