Merge branch 'joey-testing' into 'master'

Fixed date and other extras

See merge request !132
This commit was merged in pull request #136.
This commit is contained in:
Lars van Hijfte
2017-01-26 16:13:43 +01:00
8 changed files with 156 additions and 72 deletions

View File

@@ -20,15 +20,15 @@
} }
// Define variables and set to empty values // Define variables and set to empty values
$uname = $psw =""; $user = $psw ="";
$loginErr = $resetErr =""; $loginErr = $resetErr ="";
if ($_SERVER["REQUEST_METHOD"] == "POST") { if ($_SERVER["REQUEST_METHOD"] == "POST") {
switch ($_POST["submit"]) { switch ($_POST["submit"]) {
case "login": case "login":
try { try {
$uname = ($_POST["uname"]); $user = ($_POST["user"]);
validateLogin($_POST["uname"], $_POST["psw"]); validateLogin($_POST["user"], $_POST["psw"]);
} catch(loginException $e) { } catch(loginException $e) {
$loginErr = $e->getMessage(); $loginErr = $e->getMessage();
} }

View File

@@ -14,9 +14,12 @@
header("location: login.php"); header("location: login.php");
} }
// define variables and set to empty values // define variables and set to empty values
$name = $surname = $bday = $username = $password = $confirmpassword = $location = $housenumber = $email = $captcha = $ip = ""; $name = $surname = $bday = $username = $password = $confirmpassword = $location = $housenumber = $email = $confirmEmail = $captcha = $ip = "";
$genericErr = $nameErr = $surnameErr = $bdayErr = $usernameErr = $passwordErr = $confirmpasswordErr = $locationErr = $housenumberErr = $emailErr = $captchaErr = ""; $genericErr = $nameErr = $surnameErr = $bdayErr = $usernameErr = $passwordErr = $confirmpasswordErr = $locationErr = $housenumberErr = $emailErr = $confirmEmailErr = $captchaErr = "";
$correct = true; $correct = true;
$day_date = "dag";
$month_date = "maand";
$year_date = "jaar";
// Trying to register an account // Trying to register an account
if ($_SERVER["REQUEST_METHOD"] == "POST") { if ($_SERVER["REQUEST_METHOD"] == "POST") {
@@ -38,7 +41,10 @@
} }
try{ try{
$bday = test_input(($_POST["bday"])); $day_date = test_input(($_POST["day_date"]));
$month_date = test_input(($_POST["month_date"]));
$year_date = test_input(($_POST["year_date"]));
$bday = $year_date . "-" . $month_date . "-" . $day_date;
checkInputChoice($bday, "bday"); checkInputChoice($bday, "bday");
} catch(bdayException $e){ } catch(bdayException $e){
$correct = false; $correct = false;
@@ -76,9 +82,14 @@
try{ try{
$email = test_input(($_POST["email"])); $email = test_input(($_POST["email"]));
checkInputChoice($email, "email"); checkInputChoice($email, "email");
$confirmEmail = test_input(($_POST["confirmEmail"]));
matchEmail();
} catch(emailException $e){ } catch(emailException $e){
$correct = false; $correct = false;
$emailErr = $e->getMessage(); $emailErr = $e->getMessage();
} catch(confirmEmailException $e){
$correct = false;
$confirmEmailErr = $e->getMessage();
} }
try{ try{

View File

@@ -133,6 +133,10 @@ label {
width: 45%; width: 45%;
} }
select{
width: 18%;
}
ul { ul {
font-family: Arial; font-family: Arial;
font-size: 16px; font-size: 16px;
@@ -203,7 +207,6 @@ ul {
.modal-body {padding: 2px 16px;} .modal-body {padding: 2px 16px;}
.modal-footer { .modal-footer {
padding: 2px 16px;
background-color: #FBC02D; background-color: #FBC02D;
color: black; color: black;
} }

View File

@@ -38,8 +38,7 @@ function checkName($variable){
if (empty($variable)) { if (empty($variable)) {
throw new lettersAndSpacesException("Verplicht!"); throw new lettersAndSpacesException("Verplicht!");
} else if (!preg_match("/^[a-zA-Z ]*$/", $variable)) { } else if (!preg_match("/^[a-zA-Z ]*$/", $variable)) {
throw new lettersAndSpacesException("Alleen letters en spaties zijn toegestaan!");
throw new lettersAndSpacesException("Alleen letters en spaties zijn toegestaan!");
} }
} }
@@ -48,12 +47,12 @@ function validateBday($variable){
if (empty($variable)) { if (empty($variable)) {
throw new bdayException("Verplicht!"); throw new bdayException("Verplicht!");
} else { } else {
if (!(validateDate($variable, "Y/m/d"))) { if (!(validateDate($variable, "Y-m-d"))) {
throw new bdayException("Geen geldige datum"); throw new bdayException("Geen geldige datum");
} else { } else {
$dateNow = date("Y/m/d"); $dateNow = date("Y-m-d");
if ($dateNow < $variable) { if ($dateNow < $variable) {
throw new bdayException("Geen geldige datum"); throw new bdayException("Geen geldige datum!");
} }
} }
} }
@@ -97,6 +96,12 @@ function validateEmail($variable){
} }
} }
function matchEmail(){
if (strtolower($_POST["email"]) != strtolower($_POST["confirmEmail"])){
throw new confirmEmailException("Emails matchen niet!");
}
}
/* checks if an input is a valid email. */ /* checks if an input is a valid email. */
function resetEmail($variable){ function resetEmail($variable){
if (empty($variable)) { if (empty($variable)) {
@@ -206,6 +211,14 @@ class emailException extends Exception
} }
} }
class confirmEmailException extends Exception
{
public function __construct($message = "", $code = 0, Exception $previous = null)
{
parent::__construct($message, $code, $previous);
}
}
class captchaException extends Exception class captchaException extends Exception
{ {
public function __construct($message = "", $code = 0, Exception $previous = null) public function __construct($message = "", $code = 0, Exception $previous = null)

View File

@@ -9,10 +9,10 @@ function getUser() {
FROM FROM
`user` `user`
WHERE WHERE
`username` LIKE :username `username` LIKE :username OR
`email` LIKE :username
"); ");
$stmt->bindParam(":username", $_POST["uname"]);
$stmt->execute(); $stmt->execute();
return $stmt->fetch(PDO::FETCH_ASSOC); return $stmt->fetch(PDO::FETCH_ASSOC);
} }
@@ -20,7 +20,7 @@ function getUser() {
function validateLogin($username, $password){ function validateLogin($username, $password){
// Empty username or password field // Empty username or password field
if (empty($username) || empty($password)) { if (empty($username) || empty($password)) {
throw new loginException("Gebruikersnaam of wachtwoord is niet ingevuld"); throw new loginException("Inloggegevens zijn niet ingevuld");
} }
else { else {
$psw = test_input($password); $psw = test_input($password);

View File

@@ -10,7 +10,7 @@ function getExistingUsername() {
`username` LIKE :username `username` LIKE :username
"); ");
$stmt->bindParam(":username", $_POST["username"]); $stmt->bindParam(":username", test_input($_POST["username"]));
$stmt->execute(); $stmt->execute();
return $stmt->rowCount(); return $stmt->rowCount();
@@ -26,7 +26,7 @@ function getExistingEmail() {
`email` LIKE :email `email` LIKE :email
"); ");
$stmt->bindParam(":email", $_POST["email"]); $stmt->bindParam(":email", test_input($_POST["email"]));
$stmt->execute(); $stmt->execute();
return $stmt->rowCount(); return $stmt->rowCount();
@@ -42,7 +42,7 @@ function getResetEmail() {
`email` LIKE :email `email` LIKE :email
"); ");
$stmt->bindParam(":email", $_POST["forgotEmail"]); $stmt->bindParam(":email", test_input($_POST["forgotEmail"]));
$stmt->execute(); $stmt->execute();
return $stmt->rowCount(); return $stmt->rowCount();
@@ -70,15 +70,21 @@ function registerAccount() {
$hash=password_hash($_POST["password"], PASSWORD_DEFAULT); $hash=password_hash($_POST["password"], PASSWORD_DEFAULT);
$stmt->bindParam(":fname", $_POST["name"]); $stmt->bindParam(":fname", test_input($_POST["name"]));
$stmt->bindParam(":lname", $_POST["surname"]); $stmt->bindParam(":lname", test_input($_POST["surname"]));
$stmt->bindParam(":bday", $_POST["bday"]); $stmt->bindParam(":bday", test_input($_POST["bday"]));
$stmt->bindParam(":username", $_POST["username"]); $stmt->bindParam(":username", test_input($_POST["username"]));
$stmt->bindParam(":password", $hash); $stmt->bindParam(":password", test_input($hash));
$stmt->bindParam(":location", $_POST["location"]); $stmt->bindParam(":location", test_input($_POST["location"]));
$stmt->bindParam(":email", (strtolower($_POST["email"]))); $stmt->bindParam(":email", test_input(strtolower($_POST["email"])));
$stmt->execute(); $stmt->execute();
$stmt->rowCount(); $stmt->rowCount();
} }
function submitselect($date, $value){
if ($date == $value){
echo "selected";
}
}
?> ?>

View File

@@ -13,11 +13,11 @@
<!-- Login name --> <!-- Login name -->
<div class="login_containerlogin"> <div class="login_containerlogin">
<label><b>Gebruikersnaam</b></label> <label><b>Gebruikersnaam/Email</b></label>
<input type="text" <input type="text"
placeholder="Voer uw gebruikersnaam in" placeholder="Voer uw gebruikersnaam/email in"
name="uname" name="user"
value="<?php echo $uname ?>" value="<?php echo $user ?>"
title="Moet 6 of meer karakters bevatten" title="Moet 6 of meer karakters bevatten"
> >
</div> </div>
@@ -47,46 +47,47 @@
</form> </form>
</div> </div>
<!-- Button for going to the register screen --> <!-- Button for going to the register screen -->
<div class="login_containerlogin"> <div class="login_containerlogin">
<a href="https://myhyvesbookplus.nl/register" class="button">Registreer een account</a> <a href="https://myhyvesbookplus.nl/register" class="button">Registreer een account</a>
<!-- Trigger/Open The Modal --> <!-- Trigger/Open The Modal -->
<button id="myBtn" class="button">Wachtwoord vergeten</button> <button id="myBtn" class="button">Wachtwoord vergeten</button>
<!-- The Modal --> <!-- The Modal -->
<div id="myModal" class="modal"> <div id="myModal" class="modal">
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" <form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"
return= $correct return= $correct
method="post" method="post"
name="forgotPassword"> name="forgotPassword">
<!-- Modal content --> <!-- Modal content -->
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<span class="close">&times;</span> <span class="close">&times;</span>
<h3>Voer uw emailadres in</h3> <h3>Voer uw emailadres in</h3>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<input type="text" <input type="text"
placeholder="Voer uw email in" placeholder="Voer uw email in"
name="forgotEmail" name="forgotEmail"
title="Voer een email in"> title="Voer een email in">
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<div class="login_containerfault"><span><?php echo $resetErr; ?></span></div> <div class="login_containerfault"><span><?php echo $resetErr; ?></span></div>
<button type="submit" <button type="submit"
value="reset" value="reset"
name="submit" name="submit"
id="frm1_submit"> id="frm1_submit">
Reset password Reset password
</button> </button>
</div>
</div> </div>
</form>
</div> </div>
</form>
</div> </div>
</div>
<script> <script>
// Get the modal // Get the modal
var modal = document.getElementById('myModal'); var modal = document.getElementById('myModal');

View File

@@ -40,14 +40,52 @@
<!-- Register birthday --> <!-- Register birthday -->
<div class="login_containerregister"> <div class="login_containerregister">
<label><b>Geboortedatum</b></label> <label><b>Geboortedatum(Dag/Maand/Jaar)</b></label>
<input type="text" <!-- <input type="date"-->
name="bday" <!-- name="bday"-->
value="<?php echo $bday ?>" <!-- value="--><?php //echo $bday ?><!--"-->
id="bday" <!-- id="bday"-->
placeholder="1996/01/01" <!-- placeholder="1996/01/01"-->
data-fv-date-max="" <!-- data-fv-date-max=""-->
> <!-- data-date="" data-date-format="DD MMMM YYYY"-->
<!-- >-->
<select name="day_date" >
<option>dag</option>
<?php
for($i=1; $i<32; $i++) {
$i = sprintf("%02d", $i);
?>
<option value="<?= $i ?>" <?php submitselect($day_date, $i)?>><?= $i ?></option>
<?php
}
?>
</select>
<select name="month_date">
<option>Maand</option>
<option value="01" <?php submitselect($month_date, "01")?>>Januari</option>
<option value="02" <?php submitselect($month_date, "02")?>>Februari</option>
<option value="03" <?php submitselect($month_date, "03")?>>Maart</option>
<option value="04" <?php submitselect($month_date, "04")?>>April</option>
<option value="05" <?php submitselect($month_date, "05")?>>Mei</option>
<option value="06" <?php submitselect($month_date, "06")?>>Juni</option>
<option value="07" <?php submitselect($month_date, "07")?>>Juli</option>
<option value="08" <?php submitselect($month_date, "08")?>>Augustus</option>
<option value="09" <?php submitselect($month_date, "09")?>>September</option>
<option value="10" <?php submitselect($month_date, "10")?>>Oktober</option>
<option value="11" <?php submitselect($month_date, "11")?>>November</option>
<option value="12" <?php submitselect($month_date, "12")?>>December</option>
</select>
<select name="year_date">
<option>Jaar</option>
<?php
$year = (new DateTime)->format("Y");
for($i=$year; $i > $year - 100; $i--) {
?>
<option value="<?= $i ?>" <?php submitselect($year_date, $i)?>><?= $i ?></option>
<?php
}
?>
</select>
*<span class="error"> <?php echo $bdayErr;?></span> *<span class="error"> <?php echo $bdayErr;?></span>
</div> </div>
@@ -118,6 +156,18 @@
*<span class="error"> <?php echo $emailErr;?></span> *<span class="error"> <?php echo $emailErr;?></span>
</div> </div>
<!-- Register email -->
<div class="login_containerregister">
<label><b>Herhaal email</b></label>
<input type="text"
placeholder="Herhaal uw email"
name="confirmEmail"
value="<?php echo $confirmEmail ?>"
id="email"
title="Herhaal uw email">
*<span class="error"> <?php echo $confirmEmailErr;?></span>
</div>
<div class="login_containerregister"> <div class="login_containerregister">
<div class="g-recaptcha" data-sitekey="6Lc72xIUAAAAADumlWetgENm7NGd9Npyo0c_tYYQ"></div> <div class="g-recaptcha" data-sitekey="6Lc72xIUAAAAADumlWetgENm7NGd9Npyo0c_tYYQ"></div>
<span class="error"> <?php echo $captchaErr;?></span> <span class="error"> <?php echo $captchaErr;?></span>