Guest User

Untitled

a guest
Jul 3rd, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. <?php
  2. /* Connect to DB - put in your include or leave here, whatever. */
  3. session_start();
  4. $db = mysql_connect( 'localhost', 'user', 'password' );
  5. mysql_select_db( 'database' );
  6.  
  7. /* Connection check */
  8. if ( !$db ) {
  9. die( 'MySQL Connection failed!'); //Ends script here.
  10. }
  11. $result = mysql_query( "SELECT User, Pass FROM admin WHERE User = '" . mysql_real_escape_string($_POST['name']) . "' AND Pass = '".md5($_POST['pass'])."' LIMIT 1" );
  12. if ( $result && mysql_num_rows( $result ) == 1 ) {
  13. $user = mysql_fetch_assoc($r);
  14. $_SESSION['log']=1;
  15. $_SESSION['usr']=$_POST['name'];
  16. $_SESSION['ip']=$_SERVER['REMOTE_ADDR'];
  17. header('Location: index.php');
  18. } else {
  19. echo '<p>Invalid username/password entered, please try again.</p>'
  20. echo '<p><a href="index.php" title="Back">Back</a></p>';
  21. }
  22. mysql_close( $db );
  23. ?>
Add Comment
Please, Sign In to add comment