<?
// If form is submitted
if(isset($login)) {
// Set the variables to the posted information
$pusername = $_POST['nick'];
$ppassword = $_POST['password'];
// Change the submitted password into MD5 hash
$md5password = md5($ppassword);
// Check to see if the username and password are correct
$check = "SELECT * FROM users WHERE nickname = '$pusername' AND md5pw = '$md5password' LIMIT 1";
// Do the query
$query = mysql_query($check) or die("Failed to do query ($check) because: ".mysql_error());
// If the username / password dont match
if(mysql_num_rows($query) == 0) {
// Show the error message
echo("Your username / password are incorrect, please go <a href=\"javascript:history.back()\">back</a> and try again.");
}
else {
// Set cookies or sessions
echo LOGGEDIN;
session_start();
$_SESSION['xdloggedin'] = $pusername;
setcookie("id", "$id", time()+36000);
}} else {
// Echo the form
?>
<form method="post" name="login" action="<? $_SERVER['PHP_SELF']; ?>">
<input name="nick" type="text" class="form_username" onFocus="this.className='form_on'" onBlur="this.className='form_off'" size="10">
<input name="password" type="password" class="form_password" onFocus="this.className='form_on'" onBlur="this.className='form_off'" size="10">
<input type="submit" name="login" value="login">
</form>
<?
}
/*
• <a href="index.php?site=register">register now</a><br>
• <a href="index.php?site=lostpassword">lost password</a><br>
• <a href="index.php?site=registered_users">registered users</a><br>
*/
?>
I get an error that it can't do the cookies AND also I need to code in a function where it checks for the cookie and if they are, displays the user menu... Thanks in advance.