Marijn button #99

Merged
11166932 merged 152 commits from marijn-button into master 2017-01-23 13:25:08 +01:00
6 changed files with 113 additions and 127 deletions
Showing only changes of commit 7792ceaeeb - Show all commits

View File

@@ -1,7 +0,0 @@
<?xml version='1.0'?>
<MySQL_INIT>
<mysql_host>localhost</mysql_host>
<mysql_database>myhyvesbookplus</mysql_database>
<mysql_username>mhbp</mysql_username>
<mysql_password>qdtboXhCHJyL2szC</mysql_password>
</MySQL_INIT>

View File

@@ -15,16 +15,16 @@
// Trying to login // Trying to login
if ($_SERVER["REQUEST_METHOD"] == "POST") { if ($_SERVER["REQUEST_METHOD"] == "POST") {
$uname=strtolower($_POST["uname"]);
// Empty username or password field // Empty username or password field
if (empty($_POST["uname"]) || empty($_POST["psw"])) { if (empty($_POST["uname"]) || empty($_POST["psw"])) {
$loginErr = "Gebruikersnaam of wachtwoord is niet ingevuld"; $loginErr = "Gebruikersnaam of wachtwoord is niet ingevuld";
} }
else { else {
$psw=$_POST["psw"]; $uname = strtolower(test_input($_POST["uname"]));
$hash=getUser()["password"]; $psw = test_input($_POST["psw"]);
$userid=getUser()["userID"]; $hash = getUser()["password"];
$userid = getUser()["userID"];
// If there's an account, go to the profile page // If there's an account, go to the profile page
if(password_verify($psw, $hash)) { if(password_verify($psw, $hash)) {

View File

@@ -4,7 +4,7 @@
include("../views/login_head.php"); include("../views/login_head.php");
require_once("../queries/connect.php"); require_once("../queries/connect.php");
include_once("../queries/register.php"); include_once("../queries/register.php");
include_once("../queries/checkInput.php");
?> ?>
<body> <body>
<?php <?php
@@ -17,127 +17,25 @@
// Trying to register an account // Trying to register an account
if ($_SERVER["REQUEST_METHOD"] == "POST") { if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["name"])) { checkInputChoice("name", "lettersAndSpace");
$nameErr = "Naam is verplicht!"; checkInputChoice("surname", "lettersAndSpace");
$correct = false;
} else {
$name = test_input($_POST["name"]);
if (!preg_match("/^[a-zA-Z ]*$/",$name)) {
$nameErr = "Alleen letters en spaties zijn toegestaan!";
$correct = false;
}
}
if (empty($_POST["surname"])) {
$surnameErr = "Achternaam is verplicht!";
$correct = false;
} else {
$surname = test_input($_POST["surname"]);
if (!preg_match("/^[a-zA-Z ]*$/",$surname)) {
$surnameErr = "Alleen letters en spaties zijn toegestaan!";
$correct = false;
}
}
if (empty($_POST["bday"])) { if (empty($_POST["bday"])) {
$bdayErr = "Geboortedatum is verplicht!"; $bdayErr = "Geboortedatum is verplicht!";
$correct = false; $correct = false;
}
if (empty($_POST["username"])) {
$usernameErr = "Gebruikersnaam is verplicht!";
$correct = false;
} else { } else {
$username = test_input($_POST["username"]); $bday = test_input($_POST["bday"]);
if (strlen($username) < 6) {
$usernameErr = "Gebruikersnaam moet minstens 6 karakters bevatten";
$correct = false;
} else if (getExistingUsername() == 1){
$usernameErr = "Gebruikersnaam bestaat al";
$correct = false;
}
} }
if (empty($_POST["password"])) { checkInputChoice("username", "username");
$passwordErr = "Wachtwoord is verplicht!"; checkInputChoice("password", "longerEigth");
$correct = false; checkInputChoice("confirmpassword", "");
matchPassword();
} else { checkInputChoice("location", "lettersAndSpace");
$password = test_input($_POST["password"]); checkInputChoice("email", "email");
if (strlen($password) < 8) { registerCheck();
$passwordErr = "Wachtwoord moet minstens 8 karakters bevatten";
$correct = false;
}
}
if (empty($_POST["confirmpassword"])) {
$confirmpasswordErr = "Herhaal wachtwoord!";
$correct = false;
}
if ($_POST["password"] != $_POST["confirmpassword"]) {
$confirmpasswordErr = "Wachtwoorden matchen niet";
$correct = false;
}
if (empty($_POST["location"])) {
$locationErr = "Straatnaam is verplicht!";
$correct = false;
} else {
$location = test_input($_POST["location"]);
if (!preg_match("/^[a-zA-Z ]*$/",$location)) {
$locationErr = "Alleen letters en spaties zijn toegestaan!";
$correct = false;
}
}
if (empty($_POST["email"])) {
$emailErr = "Email is verplicht!";
$correct = false;
} else {
$email = test_input($_POST["email"]);
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$emailErr = "Geldige email invullen!";
$correct = false;
} else if (getExistingEmail() == 1){
$emailErr = "Email bestaat al";
$correct = false;
}
}
// Checks if everything is filled in correctly
if ($correct == false){
$genericErr = "Bepaalde velden zijn verkeerd of niet ingevuld!";
} else {
registerAccount();
header("location: login.php");
}
} }
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
/* This view adds register view */ /* This view adds register view */
include("../views/register-view.php"); include("../views/register-view.php");
?> ?>

View File

@@ -0,0 +1,95 @@
<?php
function checkInputChoice($variable, $option){
if (empty($_POST[$variable])) {
$GLOBALS[$variable . "Err"] = "Verplicht!";
$GLOBALS["correct"] = false;
} else {
$GLOBALS[$variable] = test_input($_POST[$variable]);
switch ($option) {
case "lettersAndSpace":
checkonly($variable);
break;
case "username";
username($variable);
break;
case "longerEigth";
longerEigth($variable);
break;
case "email";
validateEmail($variable);
break;
default:
break;
}
}
}
function checkOnly($variable){
if (!preg_match("/^[a-zA-Z ]*$/",$GLOBALS[$variable])) {
$GLOBALS[$variable . "Err"] = "Alleen letters en spaties zijn toegestaan!";
$correct = false;
}
}
function username($variable){
if (strlen($GLOBALS[$variable]) < 6) {
$GLOBALS[$variable . "Err"] = "Gebruikersnaam moet minstens 6 karakters bevatten";
$correct = false;
} else if (getExistingUsername() == 1) {
$GLOBALS[$variable . "Err"] = "Gebruikersnaam bestaat al";
$correct = false;
}
}
function longerEigth($variable){
if (strlen($GLOBALS[$variable]) < 8) {
$GLOBALS[$variable . "Err"] = "Moet minstens 8 karakters bevatten";
$correct = false;
}
}
function validateEmail($variable){
if (!filter_var($GLOBALS[$variable], FILTER_VALIDATE_EMAIL)) {
$GLOBALS[$variable . "Err"] = "Geldige email invullen!";
$correct = false;
} else if (getExistingEmail() == 1){
$GLOBALS[$variable . "Err"] = "Email bestaat al";
$correct = false;
}
}
function matchPassword(){
if ($_POST["password"] != $_POST["confirmpassword"]) {
$GLOBALS["confirmpasswordErr"] = "Wachtwoorden matchen niet";
$GLOBALS["correct"] = false;
}
}
// Checks if everything is filled in correctly
function registerCheck(){
if ($GLOBALS["correct"] == false){
$GLOBALS["genericErr"] = "Bepaalde velden zijn verkeerd of niet ingevuld!";
} else {
registerAccount();
header("location: login.php");
}
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>

View File

@@ -46,6 +46,6 @@
</form> </form>
<!-- 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/~joey/public/register.php" class="button">Registreer een account</a> <a href="https://myhyvesbookplus.nl/register.php" class="button">Registreer een account</a>
</div> </div>
</div> </div>

View File

@@ -108,7 +108,7 @@
<!-- Register email --> <!-- Register email -->
<div class="login_containerregister"> <div class="login_containerregister">
<label><b>Email</b></label> <label><b>Email</b></label>
<input type="email" <input type="text"
placeholder="Voer uw email in" placeholder="Voer uw email in"
name="email" name="email"
value="<?php echo $email ?>" value="<?php echo $email ?>"
@@ -130,6 +130,6 @@
<!-- Button for going back to login screen --> <!-- Button for going back to login screen -->
<div class="login_containerlogin"> <div class="login_containerlogin">
<a href="https://myhyvesbookplus.nl/~joey/public/login.php" class="button">Login met een account</a> <a href="https://myhyvesbookplus.nl/login.php" class="button">Login met een account</a>
</div> </div>
</div> </div>