Show sourcecode
The following files exists in this folder. Click to view.
webbserverprogrammering/exercises/mysqlintro/kryptering/
admin.php
dbconnection.php
deletepost.php
hemlig.php
index.php
insertpost.php
lås.php
selectposts.php
updatepost.php
hemlig.php
31 lines UTF-8 Windows (CRLF)
<?php
session_start();
include ('dbconnection.php');
if (isset($_POST["namn"]) && isset($_POST["lösen"])) {
$username = $_POST["namn"];
$password = $_POST["lösen"];
$sql = "SELECT * FROM anvandareKrypt WHERE username=? " ;
$stmt = $dbconn->prepare($sql);
$data = array($username);
$stmt->execute($data);
$res = $stmt->fetch(PDO::FETCH_ASSOC);
if (password_verify($password, $res["password"])) {
if ($res["admin"] == 1) {
$_SESSION["admin"] = "true";
header("location: admin.php");
}
else{
echo "Hjärtligt välkommen";
$_SESSION["admin"] = "false";
}
}
else header("location: index.php");
}
else{
header("location: index.php");
}
?>