Advertisement
guitarman0831

Untitled

Jun 12th, 2011
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.36 KB | None | 0 0
  1. <?php
  2.    
  3.     session_start();
  4.    
  5.     $username = $_POST['username'];
  6.     $password = $_POST['password'];
  7.    
  8.     $search = array(
  9.     '@<script[^>]*?>.*?</script>@si',   // Strip out javascript
  10.     '@<[\/\!]*?[^<>]*?>@si',            // Strip out HTML tags
  11.     '@<style[^>]*?>.*?</style>@siU',    // Strip style tags properly
  12.     '@<![\s\S]*?--[ \t\n\r]*>@'         // Strip multi-line comments
  13.     );
  14.  
  15.     $password = preg_replace($search, '', $password);
  16.    
  17.     //Hash password in a new variable
  18.     $password2 = md5($password);
  19.    
  20.     require_once "/home/a7435766/public_html/scripts/dbconnect.php";
  21.    
  22.     $query = mysql_query("SELECT * FROM userstwo WHERE username = '$username' && password = '$password2'");
  23.    
  24.     if(mysql_num_rows($query) != 0) {
  25.         //Store username and password in a cookie
  26.         if(isset($_POST['remember'])) {
  27.             setcookie("username",$username,time()+3600*24*5,"/");
  28.             setcookie("password",$password,time()+3600*24*2,"/");
  29.             $_SESSION['setCookie'] = 'true';
  30.         } else {
  31.             setcookie("username","",time()-10,"/");
  32.             setcookie("password","",time()-10,"/");
  33.            
  34.             unset($_COOKIE['username']);
  35.             unset($_COOKIE['password']);
  36.         }
  37.         $_SESSION['username'] = $username;
  38.         header('Location: http://www.ohjustthatguy.com/uploads/uploads.html');
  39.     } else {
  40.         //Pass userdne as a $_GET variable
  41.         header('Location: http://www.ohjustthatguy.com/uploads/?userdne=true');
  42.     }
  43. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement