diff --git a/website/public/js/registerAndLogin.js b/website/public/js/registerAndLogin.js index 4e68a07..ef49e83 100644 --- a/website/public/js/registerAndLogin.js +++ b/website/public/js/registerAndLogin.js @@ -8,4 +8,8 @@ function checkLoggedIn() { function bannedAlert(){ alert("Your account is banned"); +} + +function emailNotConfirmed(){ + alert("Your account has not been verified yet!\nAnother email has been sent to you") } \ No newline at end of file diff --git a/website/public/login.php b/website/public/login.php index b3a00b0..de4ecab 100644 --- a/website/public/login.php +++ b/website/public/login.php @@ -5,6 +5,7 @@ require_once("../queries/connect.php"); include_once("../queries/login.php"); include_once("../queries/checkInput.php"); + include_once("../queries/emailconfirm.php"); ?> getMessage(); diff --git a/website/public/logout.php b/website/public/logout.php index 6a2ba5d..de4d7c2 100644 --- a/website/public/logout.php +++ b/website/public/logout.php @@ -1,15 +1,4 @@ - - - - - - +session_start(); +session_destroy(); +header("Location: login.php"); \ No newline at end of file diff --git a/website/public/register.php b/website/public/register.php index 84d6873..1ce4817 100644 --- a/website/public/register.php +++ b/website/public/register.php @@ -5,6 +5,7 @@ require_once("../queries/connect.php"); include_once("../queries/register.php"); include_once("../queries/checkInput.php"); + include_once("../queries/emailconfirm.php"); ?> getMessage(); } diff --git a/website/queries/emailconfirm.php b/website/queries/emailconfirm.php index 583a47b..0b3224f 100644 --- a/website/queries/emailconfirm.php +++ b/website/queries/emailconfirm.php @@ -25,7 +25,9 @@ function sendConfirmEmail(int $userID) { WHERE `userID` = :userID "); + $stmt->bindParam(":userID", $userID); + $stmt->execute(); $user = $stmt->fetch(); $email = $user["email"]; @@ -34,10 +36,7 @@ function sendConfirmEmail(int $userID) { $confirmLink = "https://myhyvesbookplus.nl/emailconfirm.php?u=$userID&h=$hash"; $subject = "Bevestig uw emailadres"; - $body = "Hallo $fname,\r\n\r\n - Klik op de onderstaande link om uw emailadres te bevestigen.\r\n\r\n - $confirmLink\r\n\r\n - Groeten MyHyvesbook+"; + $body = "Hallo $fname,\r\n\r\nKlik op de onderstaande link om uw emailadres te bevestigen.\r\n\r\n$confirmLink\r\n\r\nGroeten MyHyvesbook+"; $header = "From: MyHyvesbook+ "; mail($email, $subject, $body, $header); } \ No newline at end of file diff --git a/website/queries/login.php b/website/queries/login.php index 8605e67..2af255a 100644 --- a/website/queries/login.php +++ b/website/queries/login.php @@ -34,6 +34,11 @@ function validateLogin($username, $password){ echo ""; + } else if ($role == "unconfirmed"){ + sendConfirmEmail(getUser()["userID"]); + echo ""; } else { $_SESSION["userID"] = $userID; header("location: profile.php"); @@ -52,4 +57,5 @@ class loginException extends Exception parent::__construct($message, $code, $previous); } } -?> \ No newline at end of file +?> + diff --git a/website/queries/settings.php b/website/queries/settings.php index d3985c7..0bf8791 100644 --- a/website/queries/settings.php +++ b/website/queries/settings.php @@ -1,4 +1,6 @@ bindParam(":email", $email); $stmt->bindParam(":userID", $_SESSION["userID"]); $stmt->execute(); -// return $stmt->rowCount(); if ($stmt->rowCount()) { + sendConfirmEmail($_SESSION["userID"]); + session_destroy(); throw new HappyAlert("Emailadres is veranderd."); } else { throw new AngryAlert();