Hello stackoverflow I have created a create user form...
It looks like this...
<form action = "createuser.php" method = "post" id = "from2">
<input type ="text" id = "namn" name="namn"placeholder = "Your name" required><br>
<input type ="email" id = "usernamet" name="username"placeholder = "Email" required><br>
<input type = "password" id = "passwordet" placeholder = "Password" name = "password" required>
<div class="g-recaptcha" data-sitekey="6LcS9hkUAAAAAK_u3cxuIsGtqI3eEdFzZ8haULa3"></div>
<input class = "lgg" type= "submit" value="Create your new account!">
I use the google Recaptca to make it safe...
Then I send the form with ajax ... Looks like this
$('#from2').on('submit',function(){
if($('#namn, #usernamet, #passwordet').val()){
$.ajax({
type: "POST",
url: "createuser.php",
data: $('#from2').serialize(),
complete: function(data){
$('#namn, #usernamet, #passwordet').val('');
}
});
return false;
}
else{
alert("Insert values!");
}
});
And then the php side looks like this
<?php
some google recapcha stuff up here
$response = json_decode(curl_exec($curl));
if(!$response->success){
echo "Your user was NOT created, use another email... or are you a robot?";
}
else{
insert the user in database
}
?>
My question is how can I show the echo when response is false on the same page as my form? So the user knows if his account was created or not?!