added user id to generated tans
This commit is contained in:
parent
41829bbbf0
commit
c4c5fc1fb8
@ -13,6 +13,11 @@
|
|||||||
<!-- Bootstrap CSS -->
|
<!-- Bootstrap CSS -->
|
||||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
|
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
|
||||||
|
|
||||||
|
<script>
|
||||||
|
var PHPSESSIONUSER = '<?php echo $_SESSION['user']; ?>';
|
||||||
|
console.log(PHPSESSIONUSER);
|
||||||
|
</script>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|
||||||
@ -64,6 +69,9 @@
|
|||||||
|
|
||||||
<div id="content">
|
<div id="content">
|
||||||
<br><span> Session User: <?php echo $_SESSION['user']; ?> </span>
|
<br><span> Session User: <?php echo $_SESSION['user']; ?> </span>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Include the footer-->
|
<!-- Include the footer-->
|
||||||
|
@ -1,12 +1,18 @@
|
|||||||
window.addEventListener('load', async () => {
|
window.addEventListener('load', async () => {
|
||||||
console.log("Seite geladen");
|
console.log("Seite geladen");
|
||||||
|
|
||||||
//getNewUniqueLink();
|
//getNewUniqueLink();
|
||||||
document.getElementById('btnCreateTan').addEventListener('click' , async (event) => getNewUniqueLink());
|
document.getElementById('btnCreateTan').addEventListener('click' , async (event) => getNewUniqueLink());
|
||||||
})
|
})
|
||||||
|
|
||||||
async function getNewUniqueLink() {
|
async function getNewUniqueLink() {
|
||||||
|
const phpSessionForm = new FormData();
|
||||||
|
phpSessionForm.append("phpSession", PHPSESSIONUSER);
|
||||||
try {
|
try {
|
||||||
var firstFetch = await fetch('php/generateLink.php');
|
var firstFetch = await fetch('php/generateLink.php', {
|
||||||
|
method: 'post',
|
||||||
|
body: phpSessionForm
|
||||||
|
});
|
||||||
var jsonFirstFetch = await firstFetch.json();
|
var jsonFirstFetch = await firstFetch.json();
|
||||||
var content = document.getElementById('content');
|
var content = document.getElementById('content');
|
||||||
content.innerHTML = `${jsonFirstFetch.html}`;
|
content.innerHTML = `${jsonFirstFetch.html}`;
|
||||||
@ -32,3 +38,8 @@ document.getElementById('btnCreate').addEventListener("click" , async (event) =>
|
|||||||
console.log("Abschicken der Daten fehlerhaft!");
|
console.log("Abschicken der Daten fehlerhaft!");
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function getCookieValue(a) {
|
||||||
|
var b = document.cookie.match('(^|;)\\s*' + a + '\\s*=\\s*([^;]+)');
|
||||||
|
return b ? b.pop() : '';
|
||||||
|
}
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
$resultStr = getTanID($uniqueID);
|
$resultStr = getTanID($uniqueID);
|
||||||
|
|
||||||
$HTMLJSON = array('html' => $resultStr);
|
$HTMLJSON = array('html' => $resultStr , 'userid' => $_POST['phpSession']);
|
||||||
echo json_encode($HTMLJSON);
|
echo json_encode($HTMLJSON);
|
||||||
|
|
||||||
function insertTan($tan) {
|
function insertTan($tan) {
|
||||||
@ -19,7 +19,9 @@
|
|||||||
$stmt = $database->prepare("INSERT INTO tans (tan, userID, used) VALUES (?, ?, ?)");
|
$stmt = $database->prepare("INSERT INTO tans (tan, userID, used) VALUES (?, ?, ?)");
|
||||||
|
|
||||||
$used = false;
|
$used = false;
|
||||||
$userid = 1;
|
$userid = $_POST['phpSession'];
|
||||||
|
//$userid = $_SESSION['user'];
|
||||||
|
//$userid = $_POST['userid'];
|
||||||
$stmt->bind_param("ssi", $tan, $userid, $used);
|
$stmt->bind_param("ssi", $tan, $userid, $used);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
1
php/getSession.php
Normal file
1
php/getSession.php
Normal file
@ -0,0 +1 @@
|
|||||||
|
<?php echo json_encode($_SESSION['user']) ?>
|
@ -1,24 +0,0 @@
|
|||||||
<?php
|
|
||||||
//<!--Login-->
|
|
||||||
if(isset($_POST['login-form'])){
|
|
||||||
session_start();
|
|
||||||
require('dbConnect.php');
|
|
||||||
|
|
||||||
$name = ($_POST['loginName']);
|
|
||||||
$pswd = ($_POST['loginPassword']);
|
|
||||||
$pswd = md5($pswd);
|
|
||||||
|
|
||||||
$stmt = $database->prepare("SELECT id FROM user WHERE '$name'=user AND password='$pswd'");
|
|
||||||
$stmt->execute();
|
|
||||||
$result = $stmt->get_result();
|
|
||||||
|
|
||||||
if ($result->num_rows == 1) {
|
|
||||||
$object = $result->fetch_object();
|
|
||||||
$_SESSION['user'] = $object->id;
|
|
||||||
|
|
||||||
echo "Einloggen erfolgreich";
|
|
||||||
} else {
|
|
||||||
echo "Einloggen fehlgeschlagen";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
@ -14,7 +14,7 @@ if( (isset($_POST['loginName'])) && isset($_POST['loginPassword'])){
|
|||||||
$object = $result->fetch_object();
|
$object = $result->fetch_object();
|
||||||
$_SESSION['user'] = $object->id;
|
$_SESSION['user'] = $object->id;
|
||||||
echo "Einloggen erfolgreich";
|
echo "Einloggen erfolgreich";
|
||||||
header("refresh:2;");
|
header("refresh:1;");
|
||||||
} else {
|
} else {
|
||||||
echo "Einloggen fehlgeschlagen";
|
echo "Einloggen fehlgeschlagen";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user