I will give 200 points to whomever can fix my code to work with cookies. What I need to stay is the link to the register page, and once I am logged in, the link to logout, and a script I can use to read cookies on other pages.
Thanks to whoever solves this.
PHP:
<?php
include "connect.php";
if($loggedin == '0')
{
if(isset($_POST['submit']))
{
if((!isset($_POST['username'])) || (!isset($_POST['pass']))
|| ($_POST['username'] == '') || ($_POST['pass'] == ''))
die("Please fill out the form completely. <br><br>
<a href=index.php>Continue</a>");
$player = @mysql_query("SELECT id, username, password, registered, lastlogin FROM players WHERE username = '".$_POST['username']."'");
$player = @mysql_fetch_assoc($player);
if($player['id'] == false)
die("Sorry, that user is not in our database.<br><br>
<a href=index.php>Back</a>");
else if($player['password'] != md5($_POST['pass']))
die("Wrong password!<br><br>
<a href=index.php>Back</a>");
$_SESSION['id'] = $player['id'];
$_SESSION['username'] = $player['username'];
$_SESSION['password'] = $player['password'];
$date = date("m/d/y");
$update = @mysql_query("UPDATE players SET lastlogin = '$date' WHERE id = '".$_SESSION['id']."'");
echo 'You are now logged in.';
}
else
{
echo 'You are not logged in. <br><br>
<form action=index.php method=post>
Username: <input type=text name=username><br>
Password: <input type=password name=pass><br>
<input type=submit name=submit value=Submit>
</form>
Would you like to <a href=register.php>register?</a>';
}
}
else
{
echo 'You are logged in!
Welcome back to Wolf Magic, '.$_SESSION['username'].'!
<br><br>
<a href=logout.php>Click Here to Logout</a>';
}
?>
Thanks to whoever solves this.