Heyyy, First time poster long time readerr
I have a problem with my login system that i'm currently creating for a game. I've never been good with cookies so was hoping to grab some advice on this problem and anything to make my system work better with cookies .
login.php
-----------------------------------------
<?php
ob_start();
if(isset($_COOKIE['id']) && isset($_COOKIE['password'])) {
echo("
<br />
- <font color='#dddddd'>Welcome $username!</font><br />
- <a href='?x=bank'>Bank</a><br />
- <a href='?x=levelup'>Level Up</a><br />
- <a href='?x=members&r=edit'>Edit Profile</a><br />
- <a href='?x=members'>Member List</a><br />
- <a href='?x=logout'>Logout</a><br />
<br />
");
if($_POST['login']) {
$username = safe($_POST['username']);
$password = safe(md5($_POST['password']));
$check = mysql_query("SELECT * FROM `users` WHERE username='$username'") or die(mysql_error());
$info = mysql_fetch_array($check) or die(mysql_error());
if(mysql_num_rows($check) == 1 && $pass == $info['password']) {
setcookie(id, $info['id'], time() + 3600, "/");
setcookie(password, $password, time() + 3600, "/");
echo("<meta http-equiv='refresh' content='4;url=http://www.simplydollclothes.com/matty/index.php'>");
echo("You have successfully logged in!");
}
}
else
{
echo("
<form name='login' method='POST'>
<table width='100%'>
<tr>
<td width='25%'><font color='#dddddd'>Username</font></td>
<td width='75%'><input type='text' name='username' size='17' /></td>
</tr>
<tr>
<td width='25%'><font color='#dddddd'>Password</font></td>
<td width='75%'><input type='password' name='password' size='17' /></td>
</tr>
<tr>
<td width='25%'><input type='submit' name='login' value='Login' /></td>
<td width='75%'><a href='?x=forgotpass'>Forgot password?</a> <a href='?x=register'>Register</a></td>
</tr>
</table>
</form>
");
}
}
?>
After pressing login the page just refreshes lightning fast and no cookies are set.
Any help will be much appreciated