Made different files for login and register #142
@@ -1,5 +1,5 @@
|
|||||||
function checkLoggedIn() {
|
function checkLoggedIn() {
|
||||||
if (confirm("You are already logged in!\nDo you want to logout?\nPress ok to logout.") == true) {
|
if (confirm("U bent al ingelogd!!\nWilt u uitloggen?\nKlik ok om uit te loggen.") == true) {
|
||||||
window.location.href = "logout.php";
|
window.location.href = "logout.php";
|
||||||
} else {
|
} else {
|
||||||
window.location.href = "profile.php";
|
window.location.href = "profile.php";
|
||||||
@@ -7,9 +7,9 @@ function checkLoggedIn() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function bannedAlert(){
|
function bannedAlert(){
|
||||||
alert("Your account is banned");
|
alert("Uw account is geband!");
|
||||||
}
|
}
|
||||||
|
|
||||||
function emailNotConfirmed(){
|
function emailNotConfirmed(){
|
||||||
alert("Your account has not been verified yet!\nAnother email has been sent to you")
|
alert("Uw account is nog niet bevestigd!\nEr is een nieuwe email gestuurd om uw account te bevestigen");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,90 +1,91 @@
|
|||||||
<?php
|
<?php
|
||||||
try {
|
|
||||||
|
try {
|
||||||
$name = test_input(($_POST["name"]));
|
$name = test_input(($_POST["name"]));
|
||||||
checkInputChoice($name, "lettersAndSpaces");
|
checkInputChoice($name, "lettersAndSpaces");
|
||||||
} catch(lettersAndSpacesException $e){
|
} catch(lettersAndSpacesException $e){
|
||||||
$correct = false;
|
$correct = false;
|
||||||
$nameErr = $e->getMessage();
|
$nameErr = $e->getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$surname = test_input(($_POST["surname"]));
|
$surname = test_input(($_POST["surname"]));
|
||||||
checkInputChoice($surname, "lettersAndSpaces");
|
checkInputChoice($surname, "lettersAndSpaces");
|
||||||
}
|
}
|
||||||
catch(lettersAndSpacesException $e){
|
catch(lettersAndSpacesException $e){
|
||||||
$correct = false;
|
$correct = false;
|
||||||
$surnameErr = $e->getMessage();
|
$surnameErr = $e->getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
try{
|
try{
|
||||||
$day_date = test_input(($_POST["day_date"]));
|
$day_date = test_input(($_POST["day_date"]));
|
||||||
$month_date = test_input(($_POST["month_date"]));
|
$month_date = test_input(($_POST["month_date"]));
|
||||||
$year_date = test_input(($_POST["year_date"]));
|
$year_date = test_input(($_POST["year_date"]));
|
||||||
$bday = $year_date . "-" . $month_date . "-" . $day_date;
|
$bday = $year_date . "-" . $month_date . "-" . $day_date;
|
||||||
checkInputChoice($bday, "bday");
|
checkInputChoice($bday, "bday");
|
||||||
} catch(bdayException $e){
|
} catch(bdayException $e){
|
||||||
$correct = false;
|
$correct = false;
|
||||||
$bdayErr = $e->getMessage();
|
$bdayErr = $e->getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
try{
|
try{
|
||||||
$username = str_replace(' ', '', test_input(($_POST["username"])));
|
$username = str_replace(' ', '', test_input(($_POST["username"])));
|
||||||
checkInputChoice($username, "username");
|
checkInputChoice($username, "username");
|
||||||
} catch(usernameException $e){
|
} catch(usernameException $e){
|
||||||
$correct = false;
|
$correct = false;
|
||||||
$usernameErr = $e->getMessage();
|
$usernameErr = $e->getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
try{
|
try{
|
||||||
$password = str_replace(' ', '', test_input(($_POST["password"])));
|
$password = str_replace(' ', '', test_input(($_POST["password"])));
|
||||||
checkInputChoice($password, "longerEight");
|
checkInputChoice($password, "longerEight");
|
||||||
matchPassword();
|
matchPassword();
|
||||||
} catch(passwordException $e){
|
} catch(passwordException $e){
|
||||||
$correct = false;
|
$correct = false;
|
||||||
$passwordErr = $e->getMessage();
|
$passwordErr = $e->getMessage();
|
||||||
} catch(confirmPasswordException $e){
|
} catch(confirmPasswordException $e){
|
||||||
$correct = false;
|
$correct = false;
|
||||||
$confirmPasswordErr = $e->getMessage();
|
$confirmPasswordErr = $e->getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
try{
|
try{
|
||||||
$location = test_input(($_POST["location"]));
|
$location = test_input(($_POST["location"]));
|
||||||
checkInputChoice($location, "lettersAndSpaces");
|
checkInputChoice($location, "lettersAndSpaces");
|
||||||
} catch(lettersAndSpacesException $e){
|
} catch(lettersAndSpacesException $e){
|
||||||
$correct = false;
|
$correct = false;
|
||||||
$locationErr = $e->getMessage();
|
$locationErr = $e->getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
try{
|
try{
|
||||||
$email = test_input(($_POST["email"]));
|
$email = test_input(($_POST["email"]));
|
||||||
checkInputChoice($email, "email");
|
checkInputChoice($email, "email");
|
||||||
$confirmEmail = test_input(($_POST["confirmEmail"]));
|
$confirmEmail = test_input(($_POST["confirmEmail"]));
|
||||||
matchEmail();
|
matchEmail();
|
||||||
} catch(emailException $e){
|
} catch(emailException $e){
|
||||||
$correct = false;
|
$correct = false;
|
||||||
$emailErr = $e->getMessage();
|
$emailErr = $e->getMessage();
|
||||||
} catch(confirmEmailException $e){
|
} catch(confirmEmailException $e){
|
||||||
$correct = false;
|
$correct = false;
|
||||||
$confirmEmailErr = $e->getMessage();
|
$confirmEmailErr = $e->getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
try{
|
try{
|
||||||
$captcha = $_POST['g-recaptcha-response'];
|
$captcha = $_POST['g-recaptcha-response'];
|
||||||
checkCaptcha($captcha);
|
checkCaptcha($captcha);
|
||||||
} catch(captchaException $e){
|
} catch(captchaException $e){
|
||||||
$correct = false;
|
$correct = false;
|
||||||
$captchaErr = $e->getMessage();
|
$captchaErr = $e->getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
getIp();
|
getIp();
|
||||||
registerCheck($correct);
|
registerCheck($correct);
|
||||||
sendConfirmEmailUsername($username);
|
sendConfirmEmailUsername($username);
|
||||||
} catch(registerException $e){
|
} catch(registerException $e){
|
||||||
echo "<script>
|
echo "<script>
|
||||||
window.onload = function() {
|
window.onload = function() {
|
||||||
$('#registerModal').show();
|
$('#registerModal').show();
|
||||||
}
|
}
|
||||||
</script>";
|
</script>";
|
||||||
$genericErr = $e->getMessage();
|
$genericErr = $e->getMessage();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,6 +68,10 @@ input[type=text], input[type=password], input[type=email], input[type="date"] {
|
|||||||
width: 55%;
|
width: 55%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.middle{
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
.center{
|
.center{
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,11 +124,11 @@ function matchPassword(){
|
|||||||
/* Checks if captcha is correctly filled in */
|
/* Checks if captcha is correctly filled in */
|
||||||
function checkCaptcha($captcha){
|
function checkCaptcha($captcha){
|
||||||
if(!$captcha){
|
if(!$captcha){
|
||||||
throw new captchaException("Captcha needs to be filled in!");
|
throw new captchaException("Captcha moet ingevuld worde!");
|
||||||
} else {
|
} else {
|
||||||
$response=json_decode(file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=6Lc72xIUAAAAAPizuF3nUbklCPljVCVzgYespz8o&response=".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR']));
|
$response=json_decode(file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=6Lc72xIUAAAAAPizuF3nUbklCPljVCVzgYespz8o&response=".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR']));
|
||||||
if($response->success==false) {
|
if($response->success==false) {
|
||||||
throw new captchaException("You are a spammer!");
|
throw new captchaException("Je bent een spammer!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,9 +42,9 @@ function validateLogin($username, $password){
|
|||||||
</script>";
|
</script>";
|
||||||
} else {
|
} else {
|
||||||
$_SESSION["userID"] = $userID;
|
$_SESSION["userID"] = $userID;
|
||||||
if($_POST[rememberMe] == 1){
|
// if($_POST[rememberMe] == 1){
|
||||||
ini_set("session.gc_maxlifetime", "10");
|
// ini_set("session.gc_maxlifetime", "10");
|
||||||
}
|
// }
|
||||||
header("location: profile.php");
|
header("location: profile.php");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ function getExistingUsername() {
|
|||||||
`username` LIKE :username
|
`username` LIKE :username
|
||||||
");
|
");
|
||||||
|
|
||||||
$stmt->bindParam(":username", test_input($_POST["username"]));
|
$stmt->bindValue(":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", test_input($_POST["email"]));
|
$stmt->bindValue(":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", test_input($_POST["forgotEmail"]));
|
$stmt->bindValue(":email", test_input($_POST["forgotEmail"]));
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
return $stmt->rowCount();
|
return $stmt->rowCount();
|
||||||
|
|
||||||
@@ -70,13 +70,13 @@ function registerAccount() {
|
|||||||
|
|
||||||
$hash=password_hash($_POST["password"], PASSWORD_DEFAULT);
|
$hash=password_hash($_POST["password"], PASSWORD_DEFAULT);
|
||||||
|
|
||||||
$stmt->bindParam(":fname", test_input($_POST["name"]));
|
$stmt->bindValue(":fname", test_input($_POST["name"]));
|
||||||
$stmt->bindParam(":lname", test_input($_POST["surname"]));
|
$stmt->bindValue(":lname", test_input($_POST["surname"]));
|
||||||
$stmt->bindParam(":bday", test_input($_POST["bday"]));
|
$stmt->bindValue(":bday", test_input($_POST["bday"]));
|
||||||
$stmt->bindParam(":username", test_input($_POST["username"]));
|
$stmt->bindValue(":username", test_input($_POST["username"]));
|
||||||
$stmt->bindParam(":password", test_input($hash));
|
$stmt->bindValue(":password", test_input($hash));
|
||||||
$stmt->bindParam(":location", test_input($_POST["location"]));
|
$stmt->bindValue(":location", test_input($_POST["location"]));
|
||||||
$stmt->bindParam(":email", test_input(strtolower($_POST["email"])));
|
$stmt->bindValue(":email", test_input(strtolower($_POST["email"])));
|
||||||
|
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$stmt->rowCount();
|
$stmt->rowCount();
|
||||||
|
|||||||
@@ -11,18 +11,18 @@
|
|||||||
</select>
|
</select>
|
||||||
<select name="month_date">
|
<select name="month_date">
|
||||||
<option>Maand</option>
|
<option>Maand</option>
|
||||||
<option value="01" <?php submitselect($month_date, "01")?>>Januari</option>
|
<option value="01" <?php submitselect($month_date, "01")?>>januari</option>
|
||||||
<option value="02" <?php submitselect($month_date, "02")?>>Februari</option>
|
<option value="02" <?php submitselect($month_date, "02")?>>februari</option>
|
||||||
<option value="03" <?php submitselect($month_date, "03")?>>Maart</option>
|
<option value="03" <?php submitselect($month_date, "03")?>>maart</option>
|
||||||
<option value="04" <?php submitselect($month_date, "04")?>>April</option>
|
<option value="04" <?php submitselect($month_date, "04")?>>april</option>
|
||||||
<option value="05" <?php submitselect($month_date, "05")?>>Mei</option>
|
<option value="05" <?php submitselect($month_date, "05")?>>mei</option>
|
||||||
<option value="06" <?php submitselect($month_date, "06")?>>Juni</option>
|
<option value="06" <?php submitselect($month_date, "06")?>>juni</option>
|
||||||
<option value="07" <?php submitselect($month_date, "07")?>>Juli</option>
|
<option value="07" <?php submitselect($month_date, "07")?>>juli</option>
|
||||||
<option value="08" <?php submitselect($month_date, "08")?>>Augustus</option>
|
<option value="08" <?php submitselect($month_date, "08")?>>augustus</option>
|
||||||
<option value="09" <?php submitselect($month_date, "09")?>>September</option>
|
<option value="09" <?php submitselect($month_date, "09")?>>september</option>
|
||||||
<option value="10" <?php submitselect($month_date, "10")?>>Oktober</option>
|
<option value="10" <?php submitselect($month_date, "10")?>>oktober</option>
|
||||||
<option value="11" <?php submitselect($month_date, "11")?>>November</option>
|
<option value="11" <?php submitselect($month_date, "11")?>>november</option>
|
||||||
<option value="12" <?php submitselect($month_date, "12")?>>December</option>
|
<option value="12" <?php submitselect($month_date, "12")?>>december</option>
|
||||||
</select>
|
</select>
|
||||||
<select name="year_date">
|
<select name="year_date">
|
||||||
<option>Jaar</option>
|
<option>Jaar</option>
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<input type="text"
|
<input type="text"
|
||||||
|
class="middle"
|
||||||
placeholder="Voer uw email in"
|
placeholder="Voer uw email in"
|
||||||
name="forgotEmail"
|
name="forgotEmail"
|
||||||
title="Voer een email in">
|
title="Voer een email in">
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
<div class="login_containerlogin">
|
<div class="login_containerlogin">
|
||||||
<label><b>Gebruikersnaam/Email</b></label>
|
<label><b>Gebruikersnaam/Email</b></label>
|
||||||
<input type="text"
|
<input type="text"
|
||||||
|
class="middle"
|
||||||
placeholder="Voer uw gebruikersnaam/email in"
|
placeholder="Voer uw gebruikersnaam/email in"
|
||||||
name="user"
|
name="user"
|
||||||
value="<?php echo $user ?>"
|
value="<?php echo $user ?>"
|
||||||
@@ -26,17 +27,13 @@
|
|||||||
<div class="login_containerlogin">
|
<div class="login_containerlogin">
|
||||||
<label><b>Wachtwoord</b></label>
|
<label><b>Wachtwoord</b></label>
|
||||||
<input type="password"
|
<input type="password"
|
||||||
|
class="middle"
|
||||||
placeholder="Voer uw wachtwoord in"
|
placeholder="Voer uw wachtwoord in"
|
||||||
name="psw"
|
name="psw"
|
||||||
title="Moet minstens 8 karakters lang zijn"
|
title="Moet minstens 8 karakters lang zijn"
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="login_containerlogin">
|
|
||||||
<label><b>Onthoud mij</b></label>
|
|
||||||
<input type="checkbox" name="rememberMe" value=1><br>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Error message -->
|
<!-- Error message -->
|
||||||
<div class="login_containerfault"><span><?php echo $loginErr; ?></span></div>
|
<div class="login_containerfault"><span><?php echo $loginErr; ?></span></div>
|
||||||
|
|
||||||
@@ -49,6 +46,11 @@
|
|||||||
Inloggen
|
Inloggen
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="login_containerlogin">
|
||||||
|
<label><b>Onthoud mij</b></label>
|
||||||
|
<input type="checkbox" name="rememberMe" value=1><br>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -78,7 +80,10 @@ var registerSpan = document.getElementsByClassName("close")[1];
|
|||||||
|
|
||||||
// When the user clicks the button, open the modal
|
// When the user clicks the button, open the modal
|
||||||
btn.onclick = function () {
|
btn.onclick = function () {
|
||||||
|
// modal.style.display = "block";
|
||||||
modal.style.display = "block";
|
modal.style.display = "block";
|
||||||
|
window.onload=emailSent();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
registerBtn.onclick = function () {
|
registerBtn.onclick = function () {
|
||||||
|
|||||||
@@ -19,6 +19,8 @@
|
|||||||
return= $correct
|
return= $correct
|
||||||
method="post">
|
method="post">
|
||||||
|
|
||||||
|
<div class="login_containerregister"><label>U krijgt een bevestigingsemail na het registreren</label></div>
|
||||||
|
|
||||||
<!-- Error message -->
|
<!-- Error message -->
|
||||||
<div class="login_containerfault"><?php echo $genericErr;?></span></div>
|
<div class="login_containerfault"><?php echo $genericErr;?></span></div>
|
||||||
|
|
||||||
@@ -135,7 +137,8 @@
|
|||||||
</div>
|
</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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user