<?php
include("db/db.php");
session_start();

$error = "";

if ($_SERVER["REQUEST_METHOD"] == "POST") {

    $myusername = mysqli_real_escape_string($db, $_POST['username']);
    $mypassword = mysqli_real_escape_string($db, $_POST['password']);

    $sql = "SELECT * FROM users WHERE email = '$myusername' and password = '$mypassword' and val='1' and web_portal='1'";
    $result = mysqli_query($db, $sql);

    if ($result->num_rows > 0) {
        while ($row = $result->fetch_assoc()) {
            $_SESSION['user_name'] = $row["full_name"]; // . ' ' . $row["last_name"]
            $_SESSION['user_id'] = $row["id"];
            $_SESSION['user_type_id'] = $row["role_id"];
            $_SESSION['email'] = $row["email"];
            $_SESSION['loggedIn'] = true;
            $_SESSION['timestamp'] = time();
        }
        header("location: index.php");
    } else {
        $error = "Your Login Name or Password is invalid or Access Restriction";
    }
}
?>

﻿
<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <?php include 'header.php'; ?>
    <style type="text/css">
        .btn {
            padding: 12px 12px !important;
        }
    </style>
</head>

<body class="login-page">
    <div class="login-box">
        <div class="logo">
            <a href="javascript:void(0);"><b>Pick N Go</b></a>
            <small>Ceylon Experience
            </small>
        </div>
        <div class="card">
            <div class="body">
                <form id="sign_in" action="" method="POST">

                    <div class="input-group">
                        <span class="input-group-addon">
                            <i class="material-icons">person</i>
                        </span>

                        <div class="form-line">
                            <input type="text" class="form-control" name="username" placeholder="Username" required
                                autofocus>
                        </div>
                    </div>
                    <div class="input-group">
                        <span class="input-group-addon">
                            <i class="material-icons">lock</i>
                        </span>

                        <div class="form-line">
                            <input type="password" class="form-control" name="password" placeholder="Password" required>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-xs-8 p-t-5">
                            <input type="checkbox" name="rememberme" id="rememberme" class="filled-in chk-col-pink">
                            <label for="rememberme">Remember Me</label>
                        </div>
                        <div class="col-xs-12"><?php echo '<span style="color:#FF0000;">' . $error . '</span>'; ?></div>
                    </div>

                    <div class="row">

                        <div class="col-xs-12">
                            <button class="btn btn-block bg-pink waves-effect" type="submit">SIGN IN</button>
                        </div>
                    </div>

                    <div class="row m-t-15 m-b--20">
                        <!--                        <div class="col-xs-6">-->
                        <!--                            <a href="">Register Now!</a>-->
                        <!--                        </div>-->
                        <div class="col-xs-8 align-right">
                            <a href="">Forgot Password?</a>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>

    <!-- Jquery Core Js -->
    <script src="../../plugins/jquery/jquery.min.js"></script>

    <!-- Bootstrap Core Js -->
    <script src="../../plugins/bootstrap/js/bootstrap.js"></script>

    <!-- Waves Effect Plugin Js -->
    <script src="../../plugins/node-waves/waves.js"></script>

    <!-- Validation Plugin Js -->
    <script src="../../plugins/jquery-validation/jquery.validate.js"></script>

    <!-- Custom Js -->
    <script src="../../js/admin.js"></script>
    <script src="../../js/pages/examples/sign-in.js"></script>
</body>


</html>