Advertisement
Guest User

Untitled

a guest
Jul 4th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.04 KB | None | 0 0
  1. <?php
  2.    
  3.     $formLogin = '<form action="'.$_SERVER['PHP_SELF'].'?page=login" method="post">
  4.         <label for="username">Username: </label>
  5.         <input type="text" name="username" id="username" /><br />
  6.         <label for="password">Password: </label>
  7.         <input type="password" name="password" id="password" /><br />
  8.         <input type="submit" name="login" value="Login" />
  9.     </form>';
  10.    
  11.     if($_SESSION['ingelogd'] == false) {
  12.        
  13.         echo $formLogin;
  14.        
  15.         if(isset($_POST['login'])){
  16.             if (!$_POST['username'] | !$_POST['password'] ) {
  17.  
  18.             die('You did not complete all of the required fields');
  19.  
  20.             }
  21.            
  22.             $username = strtolower($_POST['username']);
  23.             $password =  md5(strtolower($_POST['password']));
  24.             $passwordCheck =  md5(strtolower($_POST['passwordCheck']));
  25.    
  26.             // Check of de usernaam bestaat.
  27.             $checkUser = mysql_query("SELECT username FROM users WHERE username = '".$username."'") or die(mysql_error());
  28.             $checkUser2 = mysql_num_rows($checkUser);
  29.            
  30.             if ($checkUser2 == 0) {
  31.            
  32.                     die('Sorry, the username '.$_POST['username'].' does not exist. Would you like to <a href="?page=register&username='.$username.'">Register it now</a>.');
  33.    
  34.             }
  35.            
  36.             $checkPassword = mysql_query("SELECT password FROM users WHERE username = '".$username."'") or die(mysql_error());
  37.             $pwArray = mysql_fetch_array($checkPassword, MYSQL_ASSOC);
  38.            
  39.             if ($password == $pwArray['password']) {
  40.  
  41.                 setcookie("username", $username);
  42.                 setcookie("password", $password);
  43.                 echo $_COOKIE['username'];
  44.                 echo '<br />';
  45.                 echo $_COOKIE['password'];
  46.                 echo '<br />';
  47.                 echo 'hardcoded '.$username.'';
  48.                 echo '<br />';
  49.                 echo 'hardcoded '.$password.'';
  50.    
  51.                 $_SESSION['ingelogd'] = true;
  52.                
  53.                 $ref = $_SERVER['HTTP_REFERER'];
  54.                 echo '<meta http-equiv="refresh" content="3;URL='.$ref.'">';
  55.                 echo 'Hello World!';
  56.                 //die('Your password does not match with the username '.$username.'.');
  57.    
  58.             } else {
  59.                
  60.                 echo 'DIE World!';
  61.            
  62.             }
  63.            
  64.             /*echo '<pre>';
  65.             echo print_r($_POST);
  66.             echo '</pre>';*/
  67.  
  68.         }
  69.     }
  70.  
  71. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement