Fixed date and other extras #136

Merged
11057122 merged 1 commits from joey-testing into master 2017-01-26 16:13:47 +01:00
8 changed files with 156 additions and 72 deletions

View File

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

View File

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

View File

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

View File

@@ -38,7 +38,6 @@ function checkName($variable){
if (empty($variable)) {
throw new lettersAndSpacesException("Verplicht!");
} else if (!preg_match("/^[a-zA-Z ]*$/", $variable)) {
throw new lettersAndSpacesException("Alleen letters en spaties zijn toegestaan!");
}
}
@@ -48,12 +47,12 @@ function validateBday($variable){
if (empty($variable)) {
throw new bdayException("Verplicht!");
} else {
if (!(validateDate($variable, "Y/m/d"))) {
if (!(validateDate($variable, "Y-m-d"))) {
throw new bdayException("Geen geldige datum");
} else {
$dateNow = date("Y/m/d");
$dateNow = date("Y-m-d");
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. */
function resetEmail($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
{
public function __construct($message = "", $code = 0, Exception $previous = null)

View File

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

View File

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

View File

@@ -13,11 +13,11 @@
<!-- Login name -->
<div class="login_containerlogin">
<label><b>Gebruikersnaam</b></label>
<label><b>Gebruikersnaam/Email</b></label>
<input type="text"
placeholder="Voer uw gebruikersnaam in"
name="uname"
value="<?php echo $uname ?>"
placeholder="Voer uw gebruikersnaam/email in"
name="user"
value="<?php echo $user ?>"
title="Moet 6 of meer karakters bevatten"
>
</div>
@@ -47,8 +47,8 @@
</form>
</div>
<!-- Button for going to the register screen -->
<div class="login_containerlogin">
<!-- Button for going to the register screen -->
<div class="login_containerlogin">
<a href="https://myhyvesbookplus.nl/register" class="button">Registreer een account</a>
<!-- Trigger/Open The Modal -->
@@ -86,7 +86,8 @@
</form>
</div>
</div>
</div>
<script>
// Get the modal
var modal = document.getElementById('myModal');

View File

@@ -40,14 +40,52 @@
<!-- Register birthday -->
<div class="login_containerregister">
<label><b>Geboortedatum</b></label>
<input type="text"
name="bday"
value="<?php echo $bday ?>"
id="bday"
placeholder="1996/01/01"
data-fv-date-max=""
>
<label><b>Geboortedatum(Dag/Maand/Jaar)</b></label>
<!-- <input type="date"-->
<!-- name="bday"-->
<!-- value="--><?php //echo $bday ?><!--"-->
<!-- id="bday"-->
<!-- placeholder="1996/01/01"-->
<!-- 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>
</div>
@@ -118,6 +156,18 @@
*<span class="error"> <?php echo $emailErr;?></span>
</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="g-recaptcha" data-sitekey="6Lc72xIUAAAAADumlWetgENm7NGd9Npyo0c_tYYQ"></div>
<span class="error"> <?php echo $captchaErr;?></span>