Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Includes the db and form info.
- if ($_SESSION['logged'] == 1) { // User is already logged in.
- echo "Already logged in!";
- }
- else {
- if (!isset($_POST['submit'])) { // The form has not been submitted.
- echo '
- <form method="POST" action="index.php">
- <input type="text" class ="text-inp" value="Username" onFocus=this.value="" name="username" ><br />
- <input type="password" class ="text-inp" value="Password" onFocus=this.value="" name="password">
- <input type="image" src="./images/header/button_input_bg.gif" class ="button" value="Login" name="submit">
- </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.
- echo '<META HTTP-EQUIV="refresh" CONTENT="1">';
- } else { // Invalid username/password.
- echo "Incorrect username/password!"; // Stops the script with an error message.
- }
- }
- }
- mysql_close($db_connect); // Closes the connection.
- ?>
Add Comment
Please, Sign In to add comment