07-01-2008, 10:17 AM
|
#28 (permalink)
|
|
The Frequenter
Join Date: Sep 2007
Location: Near you.
Posts: 403
Thanks: 219
|
PHP Code:
<?php session_start(); // Starts the session. error_reporting(E_ALL & ~E_NOTICE); include("db_connect.php");
if ($_SESSION[‘logged’] == 1) { // User is already logged in.
header("Location: index.php"); // Goes to main page.
exit(); // Stops the rest of the script.
} else { if ($_POST) if ( ! isset($username)) { $username = ''; }
if ( ! isset($password)) { $password = ''; }
$szForm = <<<FORM <form action="users.php" name="login" method="post"> <table> <tr><td>username</td> <td><input type="text" name="username" value="{$username}" /></td> </tr>
<tr><td>password</td> <td><input type="password" name="password" value="{$password}" /></td> </tr>
<tr><td colspan="2"><input type='submit' name='login' value='login' /></td></tr> </table> </form> FORM;
echo $szForm;
$password = mysql_real_escape_string($_POST['password']); $username = mysql_real_escape_string($_POST['username']);
$q = mysql_query("SELECT * FROM users WHERE username = '$username' AND password = '$password'") or die (mysql_error()); // mySQL query
$r = mysql_num_rows($q); // Checks to see if anything is in the db.
if ($r == 1) { // There is something in the db. The username/password match up.
$_SESSION[‘logged’] = 1; // Sets the session.
header("Location: index.php"); // Goes to main page.
exit(); // Stops the rest of the script.
} else { // Invalid username/password.
exit("Incorrect username/password!"); // Stops the script with an error message.
}
}
?>
i put in the POST thing!
but still wont work ! :(
__________________
inquisitive
1. Eager to acquire knowledge.
2. Too curious; overly interested; nosy.
|
|
|
|