Added assignments for week 7

This commit is contained in:
Paul committed 2014-03-19 09:25:30 +01:00
1 parent 6be2ccd72f
commit f23115bab6
5 files changed
+68 -16

No files matched your search

+35 -4
View File
@@ -1,4 +1,30 @@
<!DOCTYPE html>
<?php
if($_POST) {
// Check if admin logged in
$connection = new mysqli('localhost', 'nieuws', 'pass', 'nieuws')
or die('Kan geen verbinding maken met MySQL');
$hash = sha1($_POST['wachtwoord'] . '31pEDJUu8bh0lUB9');
// Check password user, no SQL injection here people!
$result = $connection->query("SELECT * FROM gebruikers WHERE gebruikersnaam = '".$connection->real_escape_string($_POST['gebruikersnaam'])."' AND wachtwoord = '".$connection->real_escape_string($hash)."'");
if($result->num_rows > 0) {
session_start();
unset($_SESSION['gebruikersnaam']);
unset($_SESSION['admin']);
if($_POST['gebruikersnaam'] == 'Admin')
$_SESSION['admin'] = true;
$_SESSION['gebruikersnaam'] = $_POST['gebruikersnaam'];
header('Location: /nieuws/index.php');
exit;
}
}
?><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
@@ -29,9 +55,14 @@
<section id="middle">
<div id="datum"><?php setlocale(LC_ALL, 'nl_NL'); echo strftime("%A %e %B %Y"); ?>. Het laatste nieuws het eerst op NIEUWS.nl</div>
<form method="POST" action="index.php" class="form-signin">
<input name="email" class="input-block-level" placeholder="E-mail adres">
<input name="password" type="pasword" class="input-block-level" placeholder="Wachtwoord">
<form method="POST" class="form-signin">
<?php
if($_POST) {
echo '<div class="alert alert-error">Ongeldige gebruikersnaam en wachtwoord</div>';
}
?>
<input name="gebruikersnaam" class="input-block-level" placeholder="Gebruikersnaam">
<input name="wachtwoord" type="pasword" class="input-block-level" placeholder="Wachtwoord">
<button type="submit" class="btn btn-primary">Inloggen</button>
</form>