Problems with Netscape
| From: | Richard Kurth | Date: | Mon, 02 Jul 2001 17:19:09 +0000 |
| Subject: | Problems with Netscape | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-55876@lists.php.net to get a copy of this message | ||
I have a login form (look below) It works just perfict in IE but in
Netscape it gives me this error Not Found The requested URL /build3.0/user/
was not found on this server.
It can not find the page the thing is the page that it needs to find
is the same page the login form is on and the path to that page is set
with REQUEST_URI. I can not figure out way Netscape will not load the
page after it verifies the user. The REQUEST_URI is setting the URL
correctly which is /build3.0/user/usercontrol.php but Netscape sees it
as /build3.0/user/ . How can I fix this problem like I said it works
in IE without any problem.
function login_user($user_name, $password)
{
// Form our sql query
$result = query("SELECT * FROM customers WHERE cusername ='$user_name'");
$row = mysql_fetch_array($result);
if (($row["cusername"] == $user_name) AND ($row["cpassword"] == $password)
AND ($user_name != ""))
{
// User has been authenticated, send a cookie
$user_id = $row["cusername"];
$encryptedpassword = md5($password);
SetCookie("LoginCookie", "$user_id-$encryptedpassword", time()+500);//
3600 expires one hour from now you can increse this if you what it to last
longer
$success = 1;
} else {
$success = 0;
}
return $success;
}
function verify_auth($cookie)
{
// Split the cookie up into userid and password
$auth = explode("-", $cookie);
$query = query("SELECT * FROM customers WHERE cusername = '$auth[0]'");
$row = mysql_fetch_array($query);
$encryptedpassword = md5($row["cpassword"]);
if (($row["cusername"] == $auth[0]) AND ($encryptedpassword == $auth[1])
AND ($auth[0] != ""))
{
$success = 1;
} else {
$success = 0;
}
return $success;
}
function display_loginform()
{
global $SCRIPT_URL,$user_name;
?>
<table width="400" border="1" align="center">
<form name=login action="<?$SCRIPT_URL?>" method=post>
<tr><td bgcolor="#000000"><font face="Arial" color=white
size=2><b>Login
<b></font></td></tr>
<tr><td><font face="Arial" color=black size=2>Name <input
type="text"
name="user_name" size="10"> Password <input name="password"
type=password
value="" size=10></font></td></tr>
<tr><td><font face="Arial" color=black size=2> <input
type="submit"
value="Login"> <input type=reset
value="Clear"></font></td></tr>
</form>
</table>
<?
exit;
}
//////////////// script entry point here
$SCRIPT_URL=getenv("REQUEST_URI");
if($LoginCookie) // if cookie exists, check authenticity
{
$authenticated=verify_auth($LoginCookie);
if($authenticated==0) display_loginform();
} else {
$login=login_user($user_name,$password);
if($login==0) display_loginform();
}
// if user has logged in, the script carries on here....
$cookie_var = split("-", $LoginCookie);
// this variable contains who the user is logged in as!
$user = $cookie_var[0];
If ($user) {
$username = $user;
}else{
$username = $user_name;
}
Rest of the page Hear
Best regards,
Richard
mailto:rkurth@pacifier.com