Skip to content

Commit

Permalink
login
Browse files Browse the repository at this point in the history
  • Loading branch information
jmbluethner committed May 20, 2019
1 parent 43bed8a commit f60fb6e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
10 changes: 6 additions & 4 deletions checkLogin.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
ini_set('display_errors', 1);
ini_set('display_errors', 0);
$config = include('config.php');
$SQLhost = $config['SQLhost'];
$SQLdbname = $config['SQLdbname'];
Expand All @@ -21,20 +21,22 @@

if ($result->num_rows == 0) {
// Mail not found in db
$_GET['attempted'] = "y";
$_SESSION['attempted'] = "y";
header("Location: login.php");
die();
} else {
$_GET['attempted'] = "n";
$_SESSION['attempted'] = "n";
$sql = "SELECT password FROM users WHERE mail='$mail'";
$result = $conn->query($sql);
while($row = $result->fetch_assoc()) {
if(strtolower($row["password"]) == hash('sha512',$password)) {
$_SESSION['login'] = 'user';
$_SESSION['usermail'] = $mail;
$_SESSION['username'] = $row["username"];
header("Location: dashboard.php");
die();
} else {
$_GET['attempted'] = "y";
$_SESSION['attempted'] = "y";
header("Location: login.php");
die();
}
Expand Down
5 changes: 4 additions & 1 deletion dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<html>
<head>
<?php
ini_set('display_errors', 1);

session_start();
if($_SESSION['login'] != 'user') {
header('Location: login.php');
Expand All @@ -10,6 +12,7 @@
if(!isset($_GET['viewframe'])) {
$_GET['viewframe'] = 'home';
}

?>
<title>LAMA Server Manager</title>
<meta charset="utf-8">
Expand Down Expand Up @@ -60,7 +63,7 @@
<div class="loader"></div>
</div>
<script>showLoader()</script>
<div class="topbar_username">Sample Username</div>
<div class="topbar_username"><?php print_r($_SESSION['username']); ?></div>
<button class="topbar_back" title="One step back" onclick="goBack(); isFrameLoading();">
<i class="fas fa-chevron-left"></i>
</button>
Expand Down
14 changes: 9 additions & 5 deletions login.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,16 @@
<script src="./assets/js/functions.js"></script>
<?php

session_start();

include "./assets/php/functions.php";
if($_GET['attempted'] == "y") {
print_r("<script>spawnAlert('error','Invalid login Data');</script>");
}
if(!checkSQL()) {
print_r("<script>spawnAlert('error','SQL not connected!'); console.log('SQL Connection lost');</script>");
if(isset($_SESSION['attempted'])) {
if($_SESSION['attempted'] == "y") {
print_r("<script>spawnAlert('error','Invalid login Data');</script>");
}
if(!checkSQL()) {
print_r("<script>spawnAlert('error','SQL not connected!'); console.log('SQL Connection lost');</script>");
}
}
?>
</body>
Expand Down

0 comments on commit f60fb6e

Please sign in to comment.