Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * @author Jason
- * @copyright 2010
- */
- session_start();
- include "connect.php";
- if ( isset( $_SESSION['username'] ) && isset( $_SESSION['password'] ) )
- {
- echo "Welcome ".$_SESSION['username']."! Click <a href='logout.php'>here</a> to logout.";
- }
- else
- {
- $username = mysql_real_escape_string( strtolower( $_POST['username'] ) );
- $password = mysql_real_escape_string( $_POST['password'] );
- $submit = $_POST['submit'];
- if ( isset( $_POST['submit'] ))
- {
- if ( $username && $password )
- {
- $query = mysql_query(" SELECT * FROM users WHERE username = '$username' ");
- $numrows = mysql_num_rows( $query );
- if ( $numrows )
- {
- while ( $r = mysql_fetch_assoc( $query ) )
- {
- $dbusername = $r['username'];
- $dbpassword = $r['password'];
- }
- if ( $username == $dbusername && md5( $password ) == $dbpassword )
- {
- $_SESSION['username'] = $username;
- $_SESSION['password'] = $password;
- echo "<meta http-equiv='refresh' content='2'>You have now been logged in, please wait while you're being redirected.";
- }
- else
- {
- echo "Incorrect Password";
- }
- }
- else
- {
- echo "Username is taken!";
- }
- }
- else
- {
- echo "Please enter a username and password.";
- }
- }
- ?>
- <html>
- <form method='post' action="">
- Username: <input type="text" name="username"/><br />
- Password: <input type="password" name="password"/><br />
- <input type="submit" value="Log in" name="submit" />
- </form>
- </html>
- <a href="register.php">Register An Account</a>
- <?php
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement