Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- require('dbconnect.php');
- //$query = "SELECT wachtwoord FROM gebruikers WHERE username = $username";
- if(isset($_POST['login_button'])) {
- if(isset($_POST['gebruikersnaam']) && isset($_POST['wachtwoord'])) {
- $username = $_POST['gebruikersnaam'];
- $password = $_POST['wachtwoord'];
- $tempPassword = hash ('sha512', $password);
- $query = "SELECT * FROM gebruikers WHERE gebruikersnaam = '$username' AND wachtwoord = '$tempPassword'";
- $result = mysql_query($query) or die(mysql_error());
- $count = mysql_num_rows($result);
- if($count == 1) {
- $_SESSION['gebruikersnaam'] = $username;
- }
- else {
- echo "Wrong username or password.";
- }
- }
- }
- if(isset($_SESSION['gebruikersnaam'])) {
- $gebruikersnaam = $_SESSION['gebruikersnaam'];
- echo '<div id="ingelogd">';
- echo 'Welkom '.$gebruikersnaam.'<br />';
- echo '<a href="logout.php"> <input type="submit" name="logout" value="Log out"> </a>';
- echo '</div>';
- }
- ?>
- <!DOCTYPE html>
- <html>
- <body>
- <?php if (!isset($_SESSION['gebruikersnaam'])) { ?>
- <form method="POST" action="">
- <input type="text" name="gebruikersnaam" placeholder="Gebruikersnaam">
- <br>
- <input type="password" name="wachtwoord" placeholder="Wachtwoord">
- <input type="submit" name="login_button" value="Log in">
- <br>
- <input type="checkbox" name="onthouden" value="onthouden">
- Onthouden <a href="registreren.php" class="login">Registeren</a> <a href="#" class="login">Wachtwoord vergeten</a>
- </form>
- <?php }
- else {
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement