PHP Code:<?php // accesscontrol.php
include("common.php");
include("db.php");
$expiry = 60*60*24*365; // 365 days
session_start();
setcookie('uid', $uid, time()+$expiry, "/");
setcookie('pwd', $pwd, time()+$expiry, "/");
if(!isset($uid)) {
?>
<html>
<head>
<title> Please Log In for Access </title>
<LINK REL=STYLESHEET TYPE="text/css" HREF="stocksol.css">
</head>
<body>
<h1> Login Required </h1>
<p>blahblah .., <a href="signup.php">click here</a> blah .</p>
<p><form method="post" action="<?=$PHP_SELF?>">
Pilot Name: <input type="text" name="uid" size="8"><br>
Password: <input type="password" name="pwd" SIZE="8"><br>
<input type="submit" value="Log in">
</form></p>
</body>
</html>
<?php
exit;
}
session_register("uid");
session_register("pwd");
dbConnect("dbname");
$sql = "SELECT * FROM user WHERE userid = '$uid' AND password = PASSWORD('$pwd')";
$result = mysql_query($sql);
if (!$result) {
error("A database error occurred while checking your ".
"login details.\nIf this error persists, please ".
"contact .");
}
if (mysql_num_rows($result) == 0) {
session_unregister("uid");
session_unregister("pwd");
setcookie('uid', $uid, time()-$expiry, "/");
setcookie('pwd', $pwd, time()-$expiry, "/");
?>
<html>
<head>
<title> Access Denied </title>
<LINK REL=STYLESHEET TYPE="text/css" HREF="stocksol.css">
</head>
<body>
<h1> Access Denied </h1>
<p>Your Pilot Name or password is incorrect, or you are not a
registered user on this site. To try logging in again, click
<a href="<?=$PHP_SELF?>">here</a>. To register for instant
access, click <a href="signup.php">here</a>.</p>
</body>
</html>
<?php
exit;
}
$username = mysql_result($result,0,"userid");
$squad = mysql_result($result,0,"squad");
$faction = mysql_result($result,0,"faction");
$userlvl = mysql_result($result,0,"userlvl");
?>




Thanks alot.

But after i read this topic...gotcha...it needed to be in the first line...thx


Bookmarks