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_exis ts('goal', $_GET)) { $goal = $_GET['goal']; }
if (isset($HTTP_PO ST_VARS['userid']) && isset($HTTP_POS T_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($qu ery, $db_conn);
if (mysql_num_rows ($result) > 0) {
$HTTP_SESSION_V ARS['valid_user'] = $userid;
}
}
?>
<?
if (isset($HTTP_SE SSION_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><f orm method="post" action="authmai n.php">';
echo '<table>';
echo '<tr><td>Userid :</td><td><input type="text" name="userid"></td></tr>';
echo '<tr><td>Passwo rd:</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>';
}
?>
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_exis ts('goal', $_GET)) { $goal = $_GET['goal']; }
if (isset($HTTP_PO ST_VARS['userid']) && isset($HTTP_POS T_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($qu ery, $db_conn);
if (mysql_num_rows ($result) > 0) {
$HTTP_SESSION_V ARS['valid_user'] = $userid;
}
}
?>
<?
if (isset($HTTP_SE SSION_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><f orm method="post" action="authmai n.php">';
echo '<table>';
echo '<tr><td>Userid :</td><td><input type="text" name="userid"></td></tr>';
echo '<tr><td>Passwo rd:</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>';
}
?>
Comment