Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- $_SESSION["status"] = null;
- $_SESSION['userID'] = null;
- if(isset($_POST['loginSubmit'])){
- $errors = array();
- include 'connect.php';
- //Get entered information
- if(isset($_POST['login'])){
- $enteredLogin = $_POST['login'];
- }else{ $errors[] = "Enter a Username"; }
- if(isset($_POST['password'])){
- $enteredPass = $_POST['password'];
- }else{ $errors[] = "Enter a Password"; }
- //if any error
- if(sizeof($errors) > 0){
- displayErrors($errors[]);
- }else{
- $row = $db->query("select * from Users where username='$enteredLogin'")->fetch();
- //If username isn't found
- if(sizeof($row) < 1){
- $errors[] = "Username not found";
- } else{
- //If password is correct
- if(password_verify($enteredPass, $row['Password'])){
- $_SESSION["Status"] = $row["UserType"];
- $_SESSION['UserID'] = $row['UserID'];
- header("location: homePage.php");
- }else{$errors[]="Incorrect Password";}
- }
- //Display any errors if you get here
- displayErrors($errors);
- }
- }
- function displayErrors($errors){ ?>
- <div class='errors'>
- <ul><?php
- foreach($errors as $error){ ?>
- <li><?php echo $error ?></li><?php
- } ?>
- </ul>
- </div><?php
- }
- ?>
- <DOCTYPE html>
- <html>
- <head>
- <title>ARTech Login</title>
- <link rel="stylesheet" style="text/css" href="artech.css">
- </head>
- <body>
- <div id='loginArea'>
- <form class='forms' action='artechLogin.php' method='post'>
- Username:<input type='text' name='login'>
- Password:<input type='password' name='password'>
- <input type='submit' value='Login' name='loginSubmit'>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement