Show sourcecode
The following files exists in this folder. Click to view.
webbserverprogrammering/exercises/mysqlintro/inlogg/
admin.php
dbconnection.php
deletepost.php
hemlig.php
index.php
insertpost.php
lås.php
selectposts.php
updatepost.php
hemlig.php
28 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 användare WHERE username='$username' AND password='$password' " ;
$stmt = $dbconn->prepare($sql);
$data = array();
$stmt->execute($data);
$res = $stmt->fetch(PDO::FETCH_ASSOC);
if ( $stmt -> rowCount() == 1) {
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");
}
?>