Mijn script zegt dat hij $_POST['password'] niet kan vinden, dat vind ik eigenlijk best logisch want ik heb hem niet met de jquery meegegeven naar die $_GET...
code:
HTML:
<div class="inputCheckGroup">
<div class="inputGroup">
<img src="<?=ICON?>/eye_close.png" class="ShowPassword">
<input class="awe" type="password" name="password" id="password">
<label>Password</label>
</div>
<span class="inputCheck"></span>
</div>
<div class="inputCheckGroup">
<div class="inputGroup">
<img src="<?=ICON?>/eye_close.png" class="ShowPassword">
<input class="awe" type="password" name="rePassword" id="rePassword">
<label>Repeat Password</label>
</div>
<span class="inputCheck"></span>
</div>
PHP:
<?php
if ($_GET['action'] == "checkPassword") {
if (empty($_POST['password'])) {
?><img class="inputCheckImg" src="<?=ICON?>cross.png"><a class="inputCheckCross">Password may not be empty.</a><?
} else if (strlen($_POST['password']) < 6) {
?><img class="inputCheckImg" src="<?=ICON?>cross.png"><a class="inputCheckCross">Password must have 6 or more characters.</a><?
} else if (strlen($_POST['password']) > 30) {
?><img class="inputCheckImg" src="<?=ICON?>cross.png"><a class="inputCheckCross">Password may not be longer then 30 characters.</a><?
} else if (!preg_match('/[\'^£$%&*()}{@#~?\>\<\>,|=_+¬-]+/', $_POST['password'])) {
?><img class="inputCheckImg" src="<?=ICON?>cross.png"><a class="inputCheckCross">Password must have letters numbers and special chars.</a><?
} else {
?><img class="inputCheckImg" src="<?=ICON?>tick.png"><?
}
}
if ($_GET['action'] == "checkRePassword") {
if (empty($_POST['rePassword'])) {
?><img class="inputCheckImg" src="<?=ICON?>cross.png"><a class="inputCheckCross">This field can not be empty.</a><?
} else if ($_POST['password'] !== $_POST['rePassword']) {
?><img class="inputCheckImg" src="<?=ICON?>cross.png"><a class="inputCheckCross">The password doesn\'t match.</a><?
} else {
?><img class="inputCheckImg" src="<?=ICON?>tick.png"><?
}
}
?>
JQUERY:
$("input#password").on("keyup", function(){
var inputData = $(this);
$.ajax({
method: "POST",
url: "registerHandler.php?action=checkPassword",
data: inputData
}).done(function(data){
$(inputData).parent().next().empty().append(data);
});
});
$("input#rePassword").on("keyup", function(){
var inputData = $(this);
$.ajax({
method: "POST",
url: "registerHandler.php?action=checkRePassword",
data: inputData
}).done(function(data){
$(inputData).parent().next().empty().append(data);
});
});
Het is dus..
Ik geef eerder de $_POST['password'] wel mee. alleen kan ik die later niet opvragen in de $_GET['action'] == checkRePassword.
Omdat ik hem dus niet meegeef in de jquery.
Maar op welke manier zou ik die wel kunnen meegeven zodat ik kan checken of ze gelijk zijn!?
Groet,
Mathieu.