Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- $connect = new PDO('mysql:host=localhost;dbname=login', 'root', '');
- if(isset($_POST['login'])){
- $username = $_POST['username'];
- $password = $_POST['password'];
- $query = $connect -> prepare("SELECT COUNT('id') FORM 'users' WHERE 'username' = '$username' AND 'password' = '$password'");
- $query -> execute();
- $count = $query->fetchColumn();
- if($count == "1"){
- $_SESSION['username'] = $username;
- header('location: login.php');
- }else{
- header('location: index.php');
- }
- }
- ?>
- <form method="POST" action="" name="login">
- <input type="text" name="username">
- <input type="password" name="password">
- <input type="submit" name="login">
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement