При регистрации аккаунта идет проверка почты, никнейма и работает проверка на совместимость паролей.
Но почему-то не работает проверка на минимальное число и проверка на пустоту паролей(password & cpassword).
Проверка некнейма работает, почты тоже.
Ошибок никаких нет.
обработчик:
$username = protect($_POST['username']);
$email = protect($_POST['email']);
$password = crypt($_POST['password'], $salt);
$cpassword = crypt($_POST['cpassword'], $salt);
//email check
$email_exists = $con->prepare("SELECT * FROM users WHERE email = ?");
$email_exists->execute(array($email));
$emailchecker = $email_exists->fetch(PDO::FETCH_ASSOC);
//user check
$un_exists = $con->prepare("SELECT * FROM users WHERE username = ?");
$un_exists->execute(array($username));
$unchecker = $un_exists->fetch(PDO::FETCH_ASSOC);
if(empty($email) or empty($password) or empty($cpassword) or empty($username)) { die(toastr('danger', 'Oops! All fields are required')); }
elseif (!isValidUsername($username)) { die(toastr('danger', 'Oops! Please enter valid username')); }
elseif (!emailValid($email)) { die(toastr('danger', 'Oops! Please enter valid e-mail address')); }
elseif ($unchecker > 1) { die(toastr('danger', 'Oops! Username already taken')); }
elseif ($emailchecker > 1) { die(toastr('danger', 'Oops! Email already exists')); }
elseif ($password !== $cpassword) { die(toastr('danger', 'Oops! Your passwords does not match')); }
elseif (strlen($password) < 6) { die(toastr('danger', 'Oops! Password must be at least 6 characters')); }
elseif (strlen($username) < 4) { die(toastr('danger', 'Oops! Username must not be less than 4 characters')); }
else {
$date = date('d-m-Y H:i:s');
$stmt1 = $con->prepare("INSERT users (username, email, password, date) VALUES (:username,:email,:password, :date)");
$stmt1->bindParam("username",$username);
$stmt1->bindParam("email",$email);
$stmt1->bindParam("password",$password);
$stmt1->bindParam("date",$date);
$stmt1->execute();
html
<div class="form-group">
<label class="form-label">Password</label>
<input type="password" name="password" class="form-control">
</div>
<div class="form-group">
<label class="form-label">Confirm Password</label>
<input type="password" name="cpassword" class="form-control">
</div>