function password_strength($password) { if (strlen($password) < 8) { c_error("password must be longer than 8"); } if (!preg_match("#[0-9]+#", $password)) { c_error("Password must include at least one number!"); } if (!preg_match("#[a-zA-Z]+#", $password)) { c_error("Password must include at least one letter!"); } }
</body> </html> <?php } else { if ($_POST['newid'] == '' or $_POST['newpwd'] == '' or $_POST['newname'] == '' or $_POST['newemail'] == '' or $_POST['newaddress'] == '') { c_error('One or more required fields were left blank.\\n' . 'Please fill them in and try again.'); } // here begin sanitize and password strengh $_POST['newid'] = sanitize($_POST['newid'], "id not valid"); $_POST['newname'] = sanitize($_POST['newid'], "name not valid"); $_POST['newaddress'] = sanitize($_POST['newaddress'], "address not valid"); if ($_POST['newnotes'] != '') { $_POST['newnotes'] = sanitize($_POST['newnotes'], "note not valid"); } $_POST['newemail'] = sanitize($_POST['newemail'], "email not valid"); if (!filter_var($_POST['newemail'], FILTER_SANITIZE_EMAIL)) { c_error_reporting(-1); c_error("email not valid"); } password_strength($_POST['newpwd']); // here everything have been check $success = signUp($_POST['newid'], $_POST['newpwd'], $_POST['newname'], $_POST['newemail'], $_POST['newaddress'], $_POST['newnotes']); if ($success == TRUE) { echo "<h4>Signed up!</h4>"; header("Refresh: 3; url=index.php?signed_up=1"); die; } }