Hey Chris, I don't think that's really the problem. The page is split into two files -- the HTML form is in one file, and the PHP code that processes the form input is in another file. As such, the PHP file should never be called without having $_REQUEST set. If it is, then that means the user went there without submitting the form, so they're redirected to the login page.
I do see a major problem: You only print out the value of $_REQUEST inside the if() block that proves $_REQUEST['username'] and $_REQUEST['password'] don't exist. Of course it will be empty!
When debugging PHP applications, it helps to have descriptive messages displayed so you know exactly where the script is bombing.
During development/debugging, your PHP code should read something like this:
<?php
// login.php
if (isset($_REQUEST))
{
echo "<pre>\$_REQUEST is: ";
print_r($_REQUEST);
echo "</pre>";
}
//check for required fields
if (!isset($_REQUEST['username']) || !isset($_REQUEST['password']))
{
//header("Location:http://www.maac.bm/phpWeb/show_login.html");
exit;
}
etc...
See -- this way, you view the contents of $_REQUEST regardless of whether 'username' or 'password' are sent.
A more sophisticated approach would be to define a debugging flag to easily enable or disable debugging messages without having to comment out (or remove) all your debugging code when you don't need it anymore:
<?php // debug.inc.php
// This is the default value, but can be changed by setting it
// to something else by submitting a new value via POST or GET.
$DO_DEBUG_DEFAULT = true;
// shouldn't have to change anything below this line.
if (!isset($_SESSION['DO_DEBUG']))
{
$_SESSION['DO_DEBUG'] = $DO_DEBUG_DEFAULT;
}
$do_debug_order = array('POST', 'GET');
foreach ($do_debug_order as $src)
{
$var = &$_{$src};
if (isset($var['DO_DEBUG']))
{
// Copy new setting into session for persistence
$_SESSION['DO_DEBUG'] = $var['DO_DEBUG'];
}
}
function do_debug()
{
return $_SESSION['DO_DEBUG'];
}
function dprintr(&$var, $desc = "")
{
if (do_debug())
{
echo "<pre>" . (!empty($desc)? $desc : '');
print_r($var);
echo "</pre>\n";
}
}
function decho($str)
{
if (do_debug())
{
echo $str;
}
}
?>
<?php // some file that you're debugging.php
require_once('debug.inc.php'); // import functions
if (isset($_REQUEST))
{
dprintr($_REQUEST, '$_REQUEST'); // does print_r() if debugging is enabled
}
else
{
decho("\$_REQUEST does not exist!\n"); // prints this line if debugging is enabled
}
HTH!
Take care,
Nik
http://www.bigaction.org/