I have a BIG problem. i have created a login form and authentification for it, but i can\'t seem to make it goto another page once they have logged in. The code is below, but i don\'t know:
a) wot the code is to redirect it to another page for members, and
b) where on earth ot will go.
Any help would be appreciated!
<?
session_start(); // start session.
?>
<!-- header tags, edit to match your own, or include template header file. -->
<head>
<title>Login</title>
<head>
<body>
<?
if(!isset($Username) | !isset($Password)) {
// escape from php mode.
?>
<META http-equiv=\"Refresh\" content=\"1800;URL=<?php echo $root_url; ?>/members.htm;TARGET=_top\">
<form action=\"<?=$PHP_SELF?><?if($QUERY_STRING){ echo\"?\". $QUERY_STRING;}?>\" method=\"POST\">
<p align=\"center\">Members only. Please login to access this document.</p>
<table align=\"center\" border=\"0\">
<tr>
<th>
Username:
</th>
<th>
<input type=\"text\" name=\"Username\">
</th>
</tr>
<tr>
<th>
Password:
</th>
<th>
<input type=\"password\" name=\"Password\">
</th>
</tr>
<tr>
<th colspan=\"2\" align=\"right\">
<input type=\"submit\" value=\"Login\">
</form>
</th>
</tr>
</table>
</body>
<?
exit();
}
// If all is well so far.
session_register(\"Username\");
session_register(\"Password\"); // register username and password as session variables.
// Here you would check the supplied username and password against your database to see if they exist.
// For example, a MySQL Query, your method may differ.
mysql_connect (localhost, shane1090, drumnbass);
mysql_select_db (members);
$sql = mysql_query(\"SELECT Password FROM members WHERE Username = \'$Username\'\");
$fetch_em = mysql_fetch_array($sql);
$numrows = mysql_num_rows($sql);
if($numrows != \"0\" & $Password == $fetch_em[\"Password\"]) {
$valid_user = 1;
}
else {
$valid_user = 0;
}
// If the username exists and pass is correct, don\'t pop up the login code again.
// If info can\'t be found or verified....
if (!($valid_user))
{
session_unset(); // Unset session variables.
session_destroy(); // End Session we created earlier.
// escape from php mode.
?>
<form action=\"<?=$PHP_SELF?><?if($QUERY_STRING){ echo\"?\". $QUERY_STRING;}?>\" method=\"POST\">
<p align=\"center\">Incorrect login information, please try again. You must login to access this document.</p>
<table align=\"center\" border=\"0\">
<tr>
<th>
Username:
</th>
<th>
<input type=\"text\" name=\"Username\">
</th>
</tr>
<tr>
<th>
Password:
</th>
<th>
<input type=\"password\" name=\"Password\">
</th>
</tr>
<tr>
<th colspan=\"2\" align=\"right\">
<input type=\"submit\" value=\"Login\">
</form>
</th>
</tr>
</table>
</body>
<?
exit();
}
?>