You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 26, 2023. It is now read-only.
});
//here is php code
public function name_check(){
global $conn;
// Ajax calls this NAME CHECK code to execute
if(isset($_POST["usernamecheck"])){
echo $_POST;
$username = preg_replace('#[^a-z0-9]#i', '', $_POST['usernamecheck']);
$sql = "SELECT id FROM users WHERE username='$username'";
$query = mysqli_query($conn, $sql);
$uname_check = mysqli_num_rows($query);
if (strlen($username) < 3 || strlen($username) > 16) {
echo '<strong style="color:#F00;">3 - 16 characters please</strong>';
exit();
}
if (is_numeric($username[0])) {
echo '<strong style="color:#F00;">Usernames must begin with a letter</strong>';
exit();
}
if ($uname_check < 1) {
echo '<strong style="color:#009900;">' . $username . ' is OK</strong>';
exit();
} else {
echo '<strong style="color:#F00;">' . $username . ' is taken</strong>';
exit();
}
}
}
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I am trying to
validate
username field but post to php not working.returns error xhr failed loading$('#username').blur(function(){
var u = $("#username").val();
if(u != ""){
$("#unamestatus").html('checking ...');
$.ajax({
url:"php/name_check.php",
method:"POST",
data:{usernamecheck:u},
success:function(data){
$('#unamestatus').fadeIn().html(data);
setTimeout(function(){
$('#unamestatus').fadeOut("Slow");
}, 2000);
}
`` });
});
});
//here is php code
public function name_check(){
global $conn;
// Ajax calls this NAME CHECK code to execute
if(isset($_POST["usernamecheck"])){
echo $_POST;
}
}
The text was updated successfully, but these errors were encountered: