06-26-2008, 09:42 PM
|
#8 (permalink)
|
|
Super Moderator
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
|
So i have a new problem - help!
PHP Code:
<?php error_reporting(E_ALL & ~E_NOTICE); include("db_connect.php"); session_start(); // Starts the session.
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 (!isset($_POST[’submit’])) { // The form has not been submitted.
echo" <form action='users.php' name='login' method='post'> <table> <tr> <td> username </td> </tr> <tr> <td> <input type='text' name='$username'> </td> </tr>
<tr> <td> password </td> </tr> <tr> <td> <input type='text' name='$password'> </td> </tr> <tr> <td> </td> </tr> <tr> </tr> <tr> <td> <input type='submit' name='login' value='login'> </td> </tr> </table> </form>"; } else {
$username = form($_POST[‘username’]);
$password = md5($_POST[‘password’]); // Encrypts the password.
$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.
}
}
}
?>
no errors but the login do not work :S
|
|
|
|