Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div class="wrapper">
- <form class="form-signin" method="post" action='../db/loginCon.php'; >
- <h2 class= form-signin-heading""></h2>
- <input type="text" class="form-control" name="userName"
- placeholder="Username" autofocus="" />
- <input type="password" class="form-control" name="userPass"
- placeholder="Password" />
- <button id="btnLogin" class="btn btn-success"
- type="submit">Login</button>
- <a href="../index.php"><button class="btn btn-primary"
- type="submit">Cancel</button></a>
- <?php echo $errmsg; ?>
- </form>
- </div>
- <?php
- include ('dbConnLogin.php');
- $sql = "SELECT User_ID, User_Access, User_Name, User_Password,
- User_Type FROM tbluseraccount WHERE User_Name" = . $_POST["userName"];
- $result = $conn->query($sql);
- if($result->num_rows > 0){
- $row = $result->fetch_assoc();
- if($row["User_Name"] == ($_POST["userName"]) && $row["User_Password"] == ($_POST["userPass"])){
- //Redirect User if Access == 1 -> Admin else == 0 User
- if($row["User_Name"] == ($_POST["userName"]) && $row["User_Password"] == ($_POST["userPass"]) && $row[ "User_Access"] == 1){
- header("Location: ../views/admin-index.php");
- }
- elseif($row["User_Name"] == ($_POST["userName"]) && $row["User_Password"] == ($_POST["userPass"]) && $row["User_Access"] == 0){
- header("Location: ../views/user-index.php");
- }
- else{
- $errmsg = "Invalid Username and Password";
- }
- }
- }
- $conn->close();
- ?>
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "mydb";
- $conn = new mysqli($servername, $username, $password, $dbname);
- if($conn->connect_error){
- die("Connection failed: " . $conn->connect_error);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement