Lagde innloggingsise
This commit is contained in:
24
admin.php
24
admin.php
@@ -27,6 +27,14 @@
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<nav>
|
||||
<menu>
|
||||
<li class="selected"><a href="#">Dashbord</a></li>
|
||||
<li class="disabled"><a href="/registrering.php">Registrer passering på matpost/mål</a></li>
|
||||
<li class="disabled"><a href="/db_editor.html">Endre løperbase</a></li>
|
||||
</menu>
|
||||
</nav>
|
||||
<button class="danger" onclick="log_out()">Logg ut</button>
|
||||
<h2>Simple Form</h2>
|
||||
<form action="/runner.php" method="POST">
|
||||
<label for="password">Passord:</label><br>
|
||||
@@ -42,5 +50,21 @@
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<script>
|
||||
function log_out(){
|
||||
localStorage.removeItem("navn");
|
||||
localStorage.removeItem("passord");
|
||||
window.location.href = "/login.html";
|
||||
}
|
||||
|
||||
let xmlHttpReq = new XMLHttpRequest();
|
||||
xmlHttpReq.open("POST", "/is_authorized.php", false);
|
||||
xmlHttpReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8")
|
||||
xmlHttpReq.send("username=" + localStorage.getItem("navn")+"&"+"password=" + localStorage.getItem("passord"));
|
||||
if (xmlHttpReq.status != 200){
|
||||
window.location.href = "/login.html";
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user