I'm running PHP on Windows, but that's just the local test... in production
it will be on Apache.
I am not using PHP as a CGI. I want to perform redirection of the user's
browser if the user isn't a valid user. I don't want to use the refresh
meta tag or javascript to do this. I want to do this with some sort of
server command.
Does anyone know how to make this work? Here's my code...
<?php
session_start();
$goal = "";
if (array_key_exists('goal', $_GET)) { $goal = $_GET['goal']; }
if (isset($HTTP_POST_VARS['userid']) && isset($HTTP_POST_VARS['password']))
{
$userid = $HTTP_POST_VARS['userid'];
$password = $HTTP_POST_VARS['password'];
$db_conn = mysql_connect('localhost', 'webauth', 'webauth');
mysql_select_db('auth', $db_conn);
$query = "select * from auth where name='$userid' and
pass=password('$password')";
$result = mysql_query($query, $db_conn);
if (mysql_num_rows($result) > 0) {
$HTTP_SESSION_VARS['valid_user'] = $userid;
}
}
?>
<?
if (isset($HTTP_SESSION_VARS['valid_user'])) {
// redirection code goes here. Re-direct to value current to the value of
$goal which is a html file in the current directory http directory
} else {
if (isset($userid)) {
echo 'Could not log you in';
} else {
echo 'You are not logged in <br/>';
}
echo '<html><body><form method="post" action="authmain.php">';
echo '<table>';
echo '<tr><td>Userid:</td><td><input type="text" name="userid"></td></tr>';
echo '<tr><td>Password:</td><td><input type="password"
name="password"></td></tr>';
echo '<tr><td colspan="2" align="center"><input type="submit" value="Log
In"></td></tr>';
echo '</table></form></body></html>';
}
?>