Well this code works with Netscape.
Put this as the file your form submits to.
session_start();
include("includedb.php");//db info
$loginstr="$username"."$password";
$loginstrlen=strlen($loginstr);
if ($loginstrlen<2)
{
Header("Location: index.php", replace);
$error = 1;
session_register("error");
}
if (@$username && @$password) {
$res = @mysql_query("SELECT username,password FROM users WHERE username='$username' AND password='$password'");
if(@mysql_num_rows($res) != 0)
{
Header("Location: pageone.php", replace);
$verified_user = $username;
$verified_userpw = $password;
session_register("verified_user");
session_register("verified_userpw");
setcookie("time",$PHPSESSID,time()+600,"/College/Authentication/","cs5",0);
}
else {
Header("Location: index1.php", replace);
$error = 1;
session_register("error");
}
}
Put this in a header file on all your pages.
session_start();
//db stuff
$connection = mysql_connect("","","") or die ("Could not connect to the MySQL Server");
$db = mysql_select_db($dbname, $connection) or die ("Unable to select database.");
$connectdb1="users";
$res = @mysql_query("SELECT username FROM $connectdb1 WHERE username='$verified_user' AND password='$verified_userpw'");
if(@mysql_num_rows($res) == 0) {
Header("Location: /index.php");
$error = 2;
session_register("error");
}
put this in your login page, usually index.php.
<?
//this message is if no username/password pair is entered
if ($error==1){
echo "<font color=\"#FF0000\" face=\"arial\" size=\"2\">";
echo "Invalid Login - Please try again";
echo "</font>";
echo "<br>";
session_destroy();
}
//this message is if the wrong username/password pair is entered
if ($error==2){
echo "<font color=\"#FF0000\" face=\"arial\" size=\"2\">";
echo "Unauthorized Access";
echo "</font>";
echo "<br>";
session_destroy();
}
//this message is if the cookie has expired
if ($error==3){
echo "<font color=\"#FF0000\" face=\"arial\" size=\"2\">";
echo "Session has expired - Please Login";
echo "</font>";
echo "<br>";
session_destroy();
}
//setting the form now for input
?>
This should work, check the code for errors, sometimes i forget something 🙂. but it should work fine
-=Levi=-
P.S. if you have time, could you check my code? Its a question on the forum. I just need someone to look at it and see if they can see something i've glossed over?