Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- $noNvabar = '';
- if(isset($_SESSION['Username'])){
- header('Location: dashboard.php');//Redirect to dashboard page
- }
- include 'init.php';
- // check if user comming from http post request
- if ($_SERVER['REQUEST_METHOD'] == 'POST'){
- $username = $_POST['user'];
- $password = $_POST['pass'];
- $hashedPass = sha1($password);
- //check if the user exist in the database
- $stmt = $con->prepare("SELECT Username, Password FROM users WHERE Username = ? AND Password = ?");
- $stmt->execute(array($username, $hashedPass));
- $count = $stmt->rowCount();
- // if count > 0 this mean the database contains record about this username
- if ($count > 0) {
- echo 'welcome' . $username;
- $_SESSION['Username'] = $username; // Regester Session Nmae
- header('Location: dashboard.php');//Redirect to dashboard page
- exit();
- }
- }
- ?>
- <form class="login" action="<?php echo $_SERVER['PHP_SELF'] ?>" method="POST">
- <h4 class="text-center">Admin Login </h4>
- <input class="form-control" type="text" name="user" placeholder="Username" autocomplete="off" />
- <input class="form-control" type="password" name="pass" placeholder="Password" autocomplete="new-Password" />
- <input class="btn btn-primary btn-block " type="submit" value="login" />
- </form>
- <?php
- include $tbl . 'footer.php';
- ?>
Add Comment
Please, Sign In to add comment