Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- </head>
- <body>
- <?php
- if($_SERVER["REQUEST_METHOD"] == "post"){
- $login = $_POST["username"];
- $password =$_POST["password"];
- $passwordHash =hash("sha256", "password");
- $con = new PDO("mysql:host=localhost;dbname=chat;", "root", "");
- $con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $statement = $con->prepare("SELECT * FROM login WHERE username= ? AND passwordHash= ?");
- $statement->bindvalue(1, $login);
- $statement->bindvalue(2, $passwordHash);
- $statement->execute();
- $user = $statement->fetchObject();
- if($user === false){
- echo "niet ingelogd";
- }
- else
- {
- session_start();
- $_SESSION["user_name"] = $user->username;
- $_SESSION["user_id"] = $user->idlogin;
- Header("location:securepage.php");
- }
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement