2018-06-11 18:15:21 +02:00
|
|
|
<?php
|
|
|
|
//<!--Login-->
|
2018-06-13 19:46:32 +02:00
|
|
|
session_start();
|
2018-06-11 18:15:21 +02:00
|
|
|
require('../dbConnect.php');
|
|
|
|
|
2018-06-13 19:46:32 +02:00
|
|
|
|
2018-06-11 18:15:21 +02:00
|
|
|
$name = ($_POST['loginName']);
|
|
|
|
$pswd = ($_POST['loginPassword']);
|
2018-06-13 19:46:32 +02:00
|
|
|
// $pswd = md5($pswd);
|
|
|
|
|
|
|
|
$stmt = $database->prepare("SELECT id FROM user WHERE '$name'=user AND password='$pswd'");
|
|
|
|
$stmt->execute();
|
|
|
|
$result = $stmt->get_result();
|
2018-06-11 18:15:21 +02:00
|
|
|
|
2018-06-13 19:46:32 +02:00
|
|
|
if ($result->num_rows == 1) {
|
|
|
|
$object = $result->fetch_object();
|
|
|
|
$_SESSION['user'] = $object->id;
|
|
|
|
// header('Location: /index2.htm');
|
|
|
|
echo json_encode('Eingeloggt!');
|
|
|
|
// $stmt = $database->prepare("SELECT loggedin FROM user WHERE '$name'=user");
|
|
|
|
// $stmt->execute();
|
|
|
|
// $result = $stmt->get_result()->fetch_assoc();
|
|
|
|
// if ($result['loggedin'] == 'false') {
|
|
|
|
// $stmt = $database->prepare("UPDATE `benutzer`.`user` SET `loggedin`='true' WHERE '$name'=user");
|
|
|
|
// $stmt->execute();
|
|
|
|
// $a = "true";
|
2018-06-11 18:15:21 +02:00
|
|
|
} else {
|
2018-06-13 19:46:32 +02:00
|
|
|
$a = array('error' => 'Einlogen fehlgeschlagen!');
|
|
|
|
echo json_encode($a);
|
2018-06-11 18:15:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
?>
|