<?php
// Set hard coded password for user
/* $password = "helloworld12345 ";
$hash = password_hash($password, PASSWORD_DEFAULT);
echo $hash; */
/* if(isset($_SESSION["email"]))
{
header("location: index.php?page=welcome");
} */
/* ************** USER CREDENTIALS ************** */
/*
Email: besicomar@test.lu
Password: test12345
Email: bradpit@test.lu
Password: helloworld12345
Email: bettendorftom@test.lu
Password: PCsx1RJTPJGKZGunhb3fDZC9oDbC4Vwf6EXBeKqr
*/
?>
<!-- TODO: login code has to be in cms.php file -->
<!-- <?php
/* if (isset($_POST["BUTTON_send"])) {
if (!isset($_POST["DATA_email"], $_POST["DATA_password"]) || empty($_POST["DATA_email"]) || empty($_POST["DATA_password"])) {
$error = "Please enter both email and password.";
} else {
$email = $_POST["DATA_email"];
$password = $_POST["DATA_password"];
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
// prepare SQL query
$query = "SELECT passwordHash, firstName, lastName, email FROM user WHERE email = ?";
$stmt = mysqli_prepare($dbc, $query);
if ($stmt) {
mysqli_stmt_bind_param($stmt, "s", $email);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
$user = mysqli_fetch_assoc($result);
mysqli_stmt_close($stmt);
// verify user and password
if (!$user || !password_verify($password, $user["passwordHash"])) {
$error = "Invalid email or password.";
} else {
$_SESSION["email"] = $user["email"];
header("Location: index.php?page=cms");
exit();
}
} else {
$error = "Database error. Please try again later.";
}
}
} */
?> -->
<!-- <dialog id="error-dialog">
<div id="error-content">
<p id="error-label"><?php echo isset($error) ? $error : ""; ?></p>
<button id="btn-close-dialog">Close</button>
</div>
</dialog>
<script>
document.addEventListener("DOMContentLoaded", function () {
let errorDialog = document.getElementById("error-dialog");
let closeBtn = document.getElementById("btn-close-dialog");
// show dialog only if there's an error
// write php code inside HTML, : acts as "{" and endif acts as "}"
<?php if (isset($error)) : ?>
errorDialog.showModal();
<?php endif; ?>
// close dialog when clicking the close button
closeBtn.addEventListener("click", function () {
errorDialog.close();
});
});
</script> -->