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

Get PHP and MySQL for Dynamic Web Sites: Visual Quickpro Guide, Second 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.