Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //add slashes to the username and md5() the password
- $user = $_POST['username'];
- $pass = md5($_POST['password']);
- include("connectionDetails.php");
- $db = getConnection();
- $sql = "SELECT * from users where username='$user' AND password='$pass'";
- $result = $db->query($sql);
- //check that at least one row was returned
- foreach ($result as $row)
- {
- //start the session and register a variable
- session_start();
- session_register('username');
- //successful login code will go here...
- echo 'Success!';
- //we will redirect the user to another page where we will make sure they're logged in
- //header( "Location: checkLogin.php" );
- else
- //if nothing is returned by the query, unsuccessful login code goes here...
- echo 'Incorrect login name or password. Please try again.';
- }
- ?>
Add Comment
Please, Sign In to add comment