I’ve found this login script and I’m trying to implement it into my website but having a little trouble:
// Connects to your Database
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("testing") or die(mysql_error());
//checks cookies to make sure they are logged in
if(isset($_COOKIE['ID_my_site']))
{
$username = $_COOKIE['ID_my_site'];
$pass = $_COOKIE['Key_my_site'];
$check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error());
while($info = mysql_fetch_array( $check ))
{
//if the cookie has the wrong password, they are taken to the login page
if ($pass != $info['password'])
{
header("Location: loginscript.php");
}
//otherwise they are shown the admin area
else
{
echo "<a href=logout.php>Logout</a>";
}
}
}
else
//if the cookie does not exist, they are taken to the login screen
{
header("Location: newlogin.php");
}
I want to get rid of:
else
{
echo "<a href=logout.php>Logout</a>";
}
as it messes with my css, I just want the last part of the else statement to work but when i take it out it errors out.
how do I do this??
thanks
1 Answer