In creating a user account I want it to check if the user name is already taken if yes then it must inform the account creator that it is already taken, if not then it should proceed.
<div class="form-group row">
<label class="col-12 col-sm-3 col-form-label text-sm-right">Username</label>
<div class="col-12 col-sm-8 col-lg-6">
<input data-parsley-type="alphanum" type="text" name="username" pattern="(?=.*[a-z]).{10, }.+" required="" placeholder="" class="form-control" />
</div>
</div>
I think this js is totally wrong in incomplete but here it is. please help me fix this
<script>
$.post('class_model.php', { username: username}, function(data) {
if (data == 'yes') {
} else {
}
});
</script>
here's my class_model.php file
public function add_user($complete_name, $desgination, $email_address, $phone_number, $username, $password, $status){
$stmt = $this->conn->prepare("INSERT INTO `tbl_usermanagement` (`complete_name`, `desgination`, `email_address`, `phone_number`, `username`, `password`, `status`) VALUES(?, ?, ?, ?, ?, ?, ?)") or die($this->conn->error);
$stmt->bind_param("sssssss", $complete_name, $desgination, $email_address, $phone_number, $username, $password, $status);
if($stmt->execute()){
$stmt->close();
$this->conn->close();
return true;
}
}