Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //Includes.
- include("dbconnection.php"); //Access database connection.
- //Start the session
- session_start();
- //Delcare varibles before use.
- $_SESSION['loggedIn'];
- //Get userName and Password from login form.
- if(isset($_POST['userName']) && $_POST['userPassword']){
- $userName = $_POST['userName'];
- $userPassword = $_POST['userPassword'];
- }
- //Query to see if userName and password match.
- $query_login = "SELECT * FROM user WHERE userName =
- '$userName' AND userPassword = '$userPassword'";
- $result_login = mysql_query($query_login) or die
- ("Cannot verify user because: ".mysql_error());
- //Verification of user login.
- if(mysql_num_rows($result_login)==1){
- //Set status to logged on.
- $_SESSION['userName'];
- $_SESSION['userPassword'];
- $_SESSION['loggedIn'] = true;
- //Send user to welcome page.
- header('Location: homePage.php');
- }else{
- $_SESSION['loggedIn'] = false;
- //Display error message for incorrect details.
- $error = 'your an idiot!!.';
- }
- echo $error;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement