Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <body>
- <?php error_reporting(-1); ini_set('display_errors', 'on'); ?>
- <?php
- session_start();
- //Declare username and password variable from login form
- $username = $_POST['username'];
- $password = $_POST['password'];
- //NEW PDO WAY
- $conn = new PDO('mysql:host=localhost;dbname=basiclogin', 'root', 'Password@1');
- //$result = mysql_query($query);
- $stmt = $conn->prepare("SELECT * FROM users WHERE username=?");
- $stmt->execute(array($username));
- $row_count = $stmt->rowCount();
- $results = $stmt->fetchAll(PDO::FETCH_ASSOC);
- //Number of rows < 1 than user not found
- if($row_count < 1)
- {
- header('Location: index.php');
- }
- //$hash = hash('sha256', $results['salt'] . hash('sha256', $password) );
- //if($hash != $query['password']) //incorrect password
- //{
- //Return the user to the login page
- // header('Location: login.php');
- //}
- //else
- //{
- //Login Successful
- // $_SESSION['authlevel'] = $results['authlevel'];
- $_SESSION['is_logged_in'] = true;
- $_SESSION['member_name'] = $results['username'];
- header("location: welcome.php");
- //}
- ?>
- </body>
- </html>
Add Comment
Please, Sign In to add comment