Show sourcecode
The following files exists in this folder. Click to view.
dbconnection.php
index.html
ovn_sql1.php
ovn_sql2.php
ovn_sql3.php
1/
2/
3/
ovn_sql2.php
53 lines UTF-8 Windows (CRLF)
<?php
include('dbconnection.php');
if (isset($_POST['anvandare'])) {
try {
$anvandare = $_POST["anvandare"];
$password = $_POST["password"];
$sql = "SELECT * FROM anvandaretabell";
$stmt = $dbconn->prepare($sql);
$data = array();
$stmt->execute($data);
while ($res = $stmt->fetch(PDO::FETCH_ASSOC)) {
if ($anvandare == $res['anvandare'] && $password == $res['passw']) {
if ($res['typ'] == "adminn") {
header("Location:2/admin.php");
echo "admin";
exit;
} else {
header("Location:2/welcome.php");
echo "user";
exit;
}
}
}
} catch (PDOException $e) {
echo $sql . "<br />" . $e->getMessage();
}
}
$dbconn = null;
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>Inloggningssida</h1>
<form method="post" action="">
<label for="anvandare">Användarnamn</label> <br>
<input type="text" name="anvandare"> <br>
<label for="password">Lösenord</label> <br>
<input type="password" name="password"> <br>
<input type="submit">
</form>
</body>
</html>