Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Start the session
- session_start();
- $servername = "localhost";
- $serverUsername = "root";
- $serverPassword = "";
- $dbname = "rocthat";
- $tableNameUser = "user";
- //create connection
- $conn = new mysqli($servername, $serverUsername, $serverPassword, $dbname);
- if ($conn->connect_error)
- {
- die("connection failed". $conn->connect_error);
- }
- else
- {
- if(isset($_POST["submit"])){
- $errors = array();
- $_SESSION["username"] = $_POST["username"];
- $_SESSION["password"] = $_POST["password"];
- foreach($_POST as $key => $value)
- {
- if($value == "")
- {
- $errors[] = "vul je " . $key . "in.";
- }
- }
- $queryPassword = mysqli_query($conn, "SELECT 'password' FROM user WHERE username='".$_SESSION["username"]."'");
- $queryUsernameAndPassword = mysqli_query($conn, "SELECT * FROM user WHERE username='".$_SESSION["username"]."' AND password='".password_verify($_SESSION["password"], $queryPassword)."'");
- if(mysqli_num_rows($queryUsernameAndPassword) <= 0)
- {
- $errors[] = "geen geldig wachtwoord of username";
- }
- if(count($errors) > 0)
- {
- echo "<ul>";
- for($x = 0; $x < count($errors); $x++)
- {
- echo "<li>";
- echo $errors[$x];
- echo "<li>";
- }
- echo "</ul>";
- }
- else
- {
- echo "logged in";
- }
- }
- }
- ?>
- <html>
- <head>
- <link rel="stylesheet" type="text/css" href="../stylesheet.css">
- </head>
- <body>
- <div class="main">
- <div class="Form">
- <form method="POST" action="login.php">
- Username: <input type="text" name="username"/><br />
- Password: <input type="password" name="password"/><br />
- <input type="submit" name="submit" value="login"/>
- </form>
- </div>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement