|
When using PHP, it is common for scripts to accept parameters from HTML forms. For example if we have a HTML form as follows:
<form action="process.php" method="post">
Name: <input type="text" name="the_name" />
Address: <input type="text" name="the_address" />
<input type="submit" />
</form>
This is a simple HTML form that accepts a name (called the_name) and address (called the_address).
A simple PHP script could print out these parameters as follows:
<?php
echo $_POST['the_name']."<br />"; echo $_POST['the_address']."<br />";
?>
This will print out the name and address passed from the HTML form to the PHP script.
However, in certain cases this will not work i.e. the script will print nothing. The workaround is to use the $_REQUEST function which contains the contents of the $_GET, $_POST and $_COOKIE functions. Generally, the problem is caused by a programmer error in the HTML file e.g. the name of a form element is omitted. Also, it has been found that if the Content-Type is empty or not recognised in the HTTP message then the PHP $_POST array will be empty.
|