daily pastebin goal
31%
SHARE
TWEET

for miner

a guest Mar 17th, 2018 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <form method="post" action="login.php">              // This is login form
  2.     <?php include('errors.php'); ?>
  3.     <div class="input-group">
  4.         <label>Username</label>
  5.         <input type="text" name="username" >
  6.     </div>
  7.     <div class="input-group">
  8.         <label>Password</label>
  9.         <input type="password" name="password">
  10.     </div>
  11.     <div class="input-group">
  12.         <button type="submit" class="btn" name="login_user">Login</button>
  13.     </div>
  14.     <p>
  15.         Not yet a member? <a href="register.php">Sign up</a>
  16.     </p>
  17.   </form>
  18.  
  19.  
  20. // LOGIN script----- THIS ONE WORKS on another page i made,just changed the DB and table,it always says wrong username/password
  21. // but these are valid,also if i register new account,its set to automatically login,that works well,but once you close browser
  22. // (loggedin and username sessions) you can never login back :x i can not find whats wrong -.- took me already 2 days looking
  23. // at damn code but everything seems to be JUST RIGHT.
  24.  
  25. if (isset($_POST['login_user'])) {
  26.   $username = mysqli_real_escape_string($db, $_POST['username']);
  27.   $password = mysqli_real_escape_string($db, $_POST['password']);
  28.  
  29.   if (empty($username)) {
  30.     array_push($errors, "Username is required");
  31.   }
  32.   if (empty($password)) {
  33.     array_push($errors, "Password is required");
  34.   }
  35.  
  36.   if (count($errors) == 0) {
  37.     $password = md5($password);
  38.     $query = "SELECT * FROM neonracer WHERE username='$username' AND password='$password'";
  39.     $results = mysqli_query($db, $query);
  40.     if (mysqli_num_rows($results) == 1) {
  41.       $_SESSION['username'] = $username;
  42.       $_SESSION['loggedin'] = true;
  43.       header('location: index.php');
  44.     }else {
  45.         array_push($errors, "Wrong username/password combination");
  46.     }
  47.   }
  48. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top