From 28f31d749bf4dc5a920939c55d37a0f9f9a2b2f3 Mon Sep 17 00:00:00 2001 From: Marijn Jansen Date: Wed, 25 Jan 2017 11:16:53 +0100 Subject: [PATCH] Email confirm (: --- website/queries/emailconfirm.php | 43 ++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 website/queries/emailconfirm.php diff --git a/website/queries/emailconfirm.php b/website/queries/emailconfirm.php new file mode 100644 index 0000000..8b0031c --- /dev/null +++ b/website/queries/emailconfirm.php @@ -0,0 +1,43 @@ +prepare(" + SELECT + `userID` + FROM + `user` + WHERE + `username` = :username + "); + $stmt->bindParam(":username", $username); + $stmt->execute(); + $userID = $stmt->fetch()["username"]; + sendConfirmEmail($userID); +} + +function sendConfirmEmail(int $userID) { + $stmt = $GLOBALS["db"]->prepare(" + SELECT + `email`, + `fname` + FROM + `user` + WHERE + `userID` = :userID + "); + $stmt->bindParam(":userID", $userID); + $user = $stmt->fetch(); + + $email = $user["email"]; + $fname = $user["fname"]; + $hash = password_hash($email, PASSWORD_DEFAULT); + $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+"; + $header = "From: MyHyvesbook+ "; + mail($email, $subject, $body, $header); +} \ No newline at end of file