Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form method="post" action="login.php"> // This is login form
- <?php include('errors.php'); ?>
- <div class="input-group">
- <label>Username</label>
- <input type="text" name="username" >
- </div>
- <div class="input-group">
- <label>Password</label>
- <input type="password" name="password">
- </div>
- <div class="input-group">
- <button type="submit" class="btn" name="login_user">Login</button>
- </div>
- <p>
- Not yet a member? <a href="register.php">Sign up</a>
- </p>
- </form>
- // LOGIN script----- THIS ONE WORKS on another page i made,just changed the DB and table,it always says wrong username/password
- // but these are valid,also if i register new account,its set to automatically login,that works well,but once you close browser
- // (loggedin and username sessions) you can never login back :x i can not find whats wrong -.- took me already 2 days looking
- // at damn code but everything seems to be JUST RIGHT.
- if (isset($_POST['login_user'])) {
- $username = mysqli_real_escape_string($db, $_POST['username']);
- $password = mysqli_real_escape_string($db, $_POST['password']);
- if (empty($username)) {
- array_push($errors, "Username is required");
- }
- if (empty($password)) {
- array_push($errors, "Password is required");
- }
- if (count($errors) == 0) {
- $password = md5($password);
- $query = "SELECT * FROM neonracer WHERE username='$username' AND password='$password'";
- $results = mysqli_query($db, $query);
- if (mysqli_num_rows($results) == 1) {
- $_SESSION['username'] = $username;
- $_SESSION['loggedin'] = true;
- header('location: index.php');
- }else {
- array_push($errors, "Wrong username/password combination");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement