Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * @author Jason
- * @copyright 2010
- */
- session_start();
- $username = addslashes( $_POST['username'] );
- $password = addslashes( $_POST['password'] );
- if ( isset( $_POST['submit'] ) )
- {
- if ( $username && $password )
- {
- $connect = mysql_connect( "localhost", "root", "jason" ) or die( "Cannot connect to database!" );
- mysql_select_db( "usersystem" ) or die( "Cannot connect to database!" );
- $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 && $password == $dbpassword )
- {
- if( isset( $_SESSION['username'] ) && isset( $_SESSION['password'] ) ){
- echo 'only logged people can seee!';
- }
- else
- {
- ?>
- <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>
- <?php
- }
- }
- else
- {
- echo "Incorrect Password";
- }
- }
- else
- {
- echo "Username doesn't exist!";
- }
- }
- else
- {
- echo "Please enter a username and password.";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement