Email confirm and password change now use messagepage function.

This commit is contained in:
Marijn Jansen
2017-01-26 12:05:28 +01:00
parent 6a882bf78d
commit 44f86a4fbb
4 changed files with 77 additions and 59 deletions

View File

@@ -1,5 +1,6 @@
<?php <?php
include_once("../queries/connect.php"); include_once("../queries/connect.php");
include_once("../views/messagepage.php");
if (array_key_exists("u", $_GET) and array_key_exists("h", $_GET)) { if (array_key_exists("u", $_GET) and array_key_exists("h", $_GET)) {
$checkHash = $GLOBALS["db"]->prepare(" $checkHash = $GLOBALS["db"]->prepare("
SELECT SELECT
@@ -18,11 +19,11 @@ if (array_key_exists("u", $_GET) and array_key_exists("h", $_GET)) {
if ($role == "unconfirmed") { if ($role == "unconfirmed") {
doActivate($email); doActivate($email);
} else { } else {
echo "Ongeldige link."; messagePage("Ongeldige link.");
} }
} else { } else {
echo "Ongeldige link."; messagePage("Ongeldige link.");
} }
function doActivate(string $email) { function doActivate(string $email) {
@@ -39,11 +40,10 @@ function doActivate(string $email) {
$confirmUser->bindParam(":userID", $_GET["u"]); $confirmUser->bindParam(":userID", $_GET["u"]);
$confirmUser->execute(); $confirmUser->execute();
if ($confirmUser->rowCount()) { if ($confirmUser->rowCount()) {
echo "Email bevestigd <br /> messagePage("Email bevestigd <br />
<a href='index.php'>U wordt automatisch doorgestuurd naar de login pagina over 5 seconden.</a> "; <a href='index.php'>Klik hier om terug te gaan naar de login pagina.</a>");
header("refresh:5;url=login.php");
} }
} else { } else {
echo "Ongeldige link."; messagePage("Ongeldige link.");
} }
} }

View File

@@ -1,26 +1,30 @@
<?php <?php
include_once("../queries/connect.php"); include_once("../queries/connect.php");
include_once("../views/messagepage.php");
include_once("../views/resetpassword.php");
if ($_SERVER["REQUEST_METHOD"] == "GET") { if ($_SERVER["REQUEST_METHOD"] == "GET") {
if (array_key_exists("u", $_GET) and array_key_exists("h", $_GET)) { if (array_key_exists("u", $_GET) and array_key_exists("h", $_GET)) {
if (verifyLink($_GET["u"], $_GET["h"])) { if (verifyLink($_GET["u"], $_GET["h"])) {
include "../views/resetpassword.php"; messagePage(passwordResetFields());
} else { } else {
echo "Ongeldige link."; messagePage("Wachtwoorden komen niet overeen.");
} }
} else { } else {
echo "Ongeldige link."; messagePage("Ongeldige links");
} }
} elseif ($_SERVER["REQUEST_METHOD"] == "POST") { } elseif ($_SERVER["REQUEST_METHOD"] == "POST") {
if (verifyLink($_POST["u"], $_POST["h"])) { if (verifyLink($_POST["u"], $_POST["h"])) {
if ($_POST["password"] == $_POST["password-confirm"]) { if ($_POST["password"] == $_POST["password-confirm"]) {
changePassword(); changePassword();
echo "Wachtwoord is veranderd"; messagePage("Wachtwoord gewijzigd");
} else { } else {
echo "Wachtwoorden zijn niet hetzelfde"; messagePage("Ongeldige link");
} }
} }
} else { } else {
echo "Ongeldige link."; messagePage("Ongeldige link");
} }
function changePassword() { function changePassword() {

View File

@@ -0,0 +1,23 @@
<?php
function messagePage(string $content) {
$webpage = ("
<!DOCTYPE html>
<html>
<head>
<style>
@import url(styles/main.css);
@import url(styles/settings.css);
@import url(styles/resetpassword.css);
</style>
</head>
<body>
<div class='password-change'>
<div class='top-logo'><a href='login.php'><img src='img/top-logo.png' alt='MyHyvesbook+'/></a></div>
<div class='item-box platform'>$content</div>
</div>
</body>
</html>
");
echo $webpage;
}

View File

@@ -1,25 +1,17 @@
<!DOCTYPE html> <?php
<html> function passwordResetFields() {
<head> $username = $_GET['u'];
<style> $hash = $_GET['h'];
@import url(styles/main.css); $content ="
@import url(styles/settings.css); <form class='settings' method = 'post' >
@import url(styles/resetpassword.css);
</style>
</head>
<body>
<div class='password-change'>
<div class="top-logo"><img src="img/top-logo.png" alt="MyHyvesbook+"/></div>
<form class='settings platform item-box' method='post'>
<h5 > Voer een nieuw wachtwoord in </h5 > <h5 > Voer een nieuw wachtwoord in </h5 >
<input type="hidden" <input type = 'hidden'
name="u" name = 'u'
value="<?=$_GET["u"]?>" value = '$username'
> >
<input type="hidden" <input type = 'hidden'
name="h" name = 'h'
value="<?=$_GET["h"]?>" value = '$hash'
> >
<ul > <ul >
<li > <li >
@@ -41,7 +33,6 @@
<button type = 'submit' > Verander wachtwoord </button > <button type = 'submit' > Verander wachtwoord </button >
</li > </li >
</ul > </ul >
</form> </form >";
</div> return $content;
</body> }
</html>