Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form class="" action="" method="post">
- <?php login_user();?>
- <div class="form-group"><label for="">
- username<input type="text" name="username" class="form-control"></label>
- </div>
- <div class="form-group"><label for="password">
- Password<input type="text" name="password" class="form-control"></label>
- </div>
- <div class="form-group">
- <input type="submit" name="submit" class="btn btn-primary" >
- </div>
- </form>
- function login_user(){
- if(isset($_POST['submit'])) {
- $username = $_POST['username'];
- $password = $_POST['password'];
- $sqlQuery = "SELECT * FROM users WHERE username = \'{username\}' AND password = \'{password\}'";
- $statement = $db->prepare($sqlQuery);
- $statement->execute($username, $password);
- $data = $statement->fetch();
- if($data){
- header("location:admin");
- }else {
- header("location:login.php");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement