Login/Register/confirm and new comment feature
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
include_once "../../base/settings.php";
|
||||
include_once "../../base/headers.php";
|
||||
include_once "../../base/database.php";
|
||||
include_once "../../base/helpers.php";
|
||||
include_once "./queries.php";
|
||||
|
||||
session_name("PHP_SESSION_guestBook");
|
||||
session_start();
|
||||
|
||||
if (isset($_SESSION["user"])) {
|
||||
Headers::redirect("../");
|
||||
return;
|
||||
}
|
||||
|
||||
$_SESSION["error"] = [];
|
||||
$_SESSION["message"] = [];
|
||||
|
||||
if (!isset($_GET["c"])) {
|
||||
Headers::redirect(".");
|
||||
return;
|
||||
}
|
||||
$code = $_GET["c"];
|
||||
|
||||
$db = DB::openConnection();
|
||||
|
||||
$stmt = $db->prepare($confirmFetchUserQuery);
|
||||
$stmt->bindValue(":COD", $code);
|
||||
$stmt->execute();
|
||||
$uid = $stmt->fetch(PDO::FETCH_COLUMN);
|
||||
|
||||
if ($uid !== false) {
|
||||
$stmt = $db->prepare($confirmUserQuery);
|
||||
$stmt->bindValue(":UID", $uid);
|
||||
$stmt->execute();
|
||||
|
||||
array_push($_SESSION["message"], "Account confirmed, you can now log in!");
|
||||
} else {
|
||||
array_push($_SESSION["error"], "Account could not be confirmed");
|
||||
}
|
||||
|
||||
DB::closeConnection($db);
|
||||
|
||||
Headers::redirect("./login");
|
||||
Reference in New Issue
Block a user