| |
Here is a simple PHP example of a form GET. Save this file to
\program files\badblue\pe\formget.php and
click here to test.
<html><body>
<?php
if (!isset($_GET["username"])) {
echo('<form action="formget.php" method="GET">');
echo(' Name: <input type="text" name="username"><br>');
echo(' Company: <input type="text" name="company">');
echo(' <input type="submit" value="Go!">');
echo('</form>');
} else {
$aVar = "<b>Hello ".$_GET["username"]."</b>...<br>";
echo($aVar);
echo("Your IP address is ".$_ENV["REMOTE_ADDR"]."<br>");
echo("Today is ".date("F j, Y, g:i:s a")."<br>");
echo("Your company is ".$_GET["company"]."<br>");
}
?>
</body></html>
| Note
|
To reference form variables, you can use the
built-in arrays $_GET or $_POST for
GET and POST requests, respectively. You can also use
the $_HTTP_GET_VARS or $_HTTP_POST_VARS array, which
are just different names for the same array. The built-in
$_ENV array contains
environment variables provided
by the server.
|
|
Here is a simple PHP example of a form POST. Save this file to
\program files\badblue\pe\formpost.php and
click here to test.
<html><body>
<?php
if (!isset($_POST["username"])) {
echo('<form action="formpost.php" method="POST">');
echo(' Name: <input type="text" name="username"><br>');
echo(' Company: <input type="text" name="company">');
echo(' <input type="submit" value="Go!">');
echo('</form>');
} else {
$aVar = "<b>Hello ".$_POST["username"]."</b>...<br>";
echo($aVar);
echo("Your IP address is ".$_ENV["REMOTE_ADDR"]."<br>");
echo("Today is ".date("F j, Y, g:i:s a")."<br>");
echo("Your company is ".$_POST["company"]."<br>");
}
?>
</body></html>
|