SHOW:
|
|
- or go back to the newest paste.
| 1 | <!DOCTYPE html> | |
| 2 | ||
| 3 | <html> | |
| 4 | <?php | |
| 5 | session_start(); | |
| 6 | ||
| 7 | //instellen gebruikersnaam en wachtwoord | |
| 8 | $usernamecheck = 'admin'; | |
| 9 | $passwordcheck = 'admin'; | |
| 10 | ||
| 11 | //controle of er op submit is geklikt | |
| 12 | if($_SERVER['REQUEST_METHOD'] == 'POST') {
| |
| 13 | ||
| 14 | //controle of alles is ingevuld | |
| 15 | if(isset($_POST['user']) && isset($_POST['pass'])) {
| |
| 16 | ||
| 17 | //spaties verwijderen en omzetten naar html | |
| 18 | $user = trim($_POST['user']); | |
| 19 | $pass = trim($_POST['pass']); | |
| 20 | $user = htmlspecialchars($_POST['user']); | |
| 21 | $pass = htmlspecialchars($_POST['pass']); | |
| 22 | ||
| 23 | //gebruikersnaam en wachtwoord controleren | |
| 24 | if($user == $usernamecheck && $pass == $passwordcheck) {
| |
| 25 | ||
| 26 | //als het de juiste gegevens zijn dan inloggen | |
| 27 | $_SESSION['logged_in'] = true; | |
| 28 | $_SESSION['gebruiker'] = $user; | |
| 29 | ||
| 30 | //doorsturen naar volgende pagina | |
| 31 | header('Location: ingelogd.php');
| |
| 32 | exit; | |
| 33 | } | |
| 34 | ||
| 35 | - | else {
|
| 35 | + | elseif {
|
| 36 | //terugsturen en foutmelding geven | |
| 37 | echo 'De combinatie van gebruikersnaam en wachtwoord is onjuist'; | |
| 38 | ?> | |
| 39 | <form action = 'login_form.php'><p><input type = 'submit' value = 'Terug naar de inlogpagina' /></p></form> | |
| 40 | <?php | |
| 41 | } | |
| 42 | } | |
| 43 | ||
| 44 | - | else {
|
| 44 | + | elseif {
|
| 45 | - | echo 'Niet alles is ingevuld'; |
| 45 | + | echo 'Niet alles is ingevuld'; |
| 46 | - | ?> |
| 46 | + | |
| 47 | - | <form action = 'login_form.php'><p><input type = 'submit' value = 'Terug naar de inlogpagina' /></p></form> |
| 47 | + | |
| 48 | - | <?php |
| 48 | + | |
| 49 | } | |
| 50 | } | |
| 51 | - | else {
|
| 51 | + | else {
|
| 52 | - | //terug naar de inlogpagina |
| 52 | + | //terug naar de inlogpagina |
| 53 | - | header('Location: login_form.php');
|
| 53 | + | header('Location: login_form.php');
|
| 54 | - | exit(); |
| 54 | + | exit(); |
| 55 | } | |
| 56 | ?> | |
| 57 | </html> |