Email confirm and password change now use messagepage function. #131

Merged
11166932 merged 1 commits from marijn-messagePage into master 2017-01-26 12:06:39 +01:00
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,47 +1,38 @@
<!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); <h5 > Voer een nieuw wachtwoord in </h5 >
</style> <input type = 'hidden'
</head> name = 'u'
<body> value = '$username'
<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>
<input type="hidden"
name="u"
value="<?=$_GET["u"]?>"
> >
<input type="hidden" <input type = 'hidden'
name="h" name = 'h'
value="<?=$_GET["h"]?>" value = '$hash'
> >
<ul> <ul >
<li> <li >
<label>Nieuw wachtwoord</label> <label > Nieuw wachtwoord </label >
<input type='password' <input type = 'password'
name='password' name = 'password'
placeholder='Nieuw wachtwoord' placeholder = 'Nieuw wachtwoord'
> >
</li> </li >
<li> <li >
<label>Bevestig wachtwoord</label> <label > Bevestig wachtwoord </label >
<input type='password' <input type = 'password'
name='password-confirm' name = 'password-confirm'
placeholder='Bevestig wachtwoord' placeholder = 'Bevestig wachtwoord'
> >
</li> </li >
<li> <li >
<label></label> <label ></label >
<button type='submit'>Verander wachtwoord</button> <button type = 'submit' > Verander wachtwoord </button >
</li> </li >
</ul> </ul >
</form> </form >";
</div> return $content;
</body> }
</html>