O'Reilly logo

PHP and MySQL for Dynamic Web Sites: Visual Quickpro Guide, Second Edition by Larry Ullman

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

Sending Values to a Script Manually

In the examples so far, all of the data received in the PHP script came from what the user entered in a form. There are, however, two different ways you can pass variables and values to a PHP script, 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 $_POST['name'] will have a value of Brian in the handling PHP script (assuming that the form uses the POST method). This technique will be demonstrated shortly.

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

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

This technique emulates the GET method of an HTML ...

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