/    Sign up×
Community /Pin to ProfileBookmark

jquery validate

Hello friends. I am denying with the validation with jquery validate to know if a user exists in the database at login. I am getting an “undefined” error, I don’t know if the error will be in the json handling. I hope you can help me.

html:

[code]<form method=”post” name=”myemailform” id=”myemailform” action=”#” >
<p>
<label for=’email’>Email Address:</label><br>
<input type=”text” name=”email” id=”user_nickname” >
</p>
<input type=”submit” name=’submit’ value=”Post it !”>
</form>

js:
$(“#myemailform”).validate({
rules: {
’email’:{
required: true,
email: true,
remote:{
url: “chek-email.php”,
type: “post”
}
}
},
messages: {

email:
{
required: “The Email is required!”,

email: “Please enter a valid email address!”,

remote: “The email is already in use by another user!”
}
},
submitHandler: function (form) { // for demo
alert(‘valid form submitted’); // for demo
return false; // for demo
}
});[/code]

chek-email.php:

[code]function isset_email($email){

global $conn;
$email = trim($email);

$query = “SELECT COUNT(*) AS num FROM tb_usuario WHERE mailUsuario='” .mysqli_real_escape_string($conn,$email). “‘”;

$result = mysqli_query($conn,$query);
$row = mysqli_fetch_array($result);

if($row[‘num’]>=1){
return TRUE; // Si el usuario existe
}
else{
return FALSE; // Si el usuario no existe
}

}[/code]

to post a comment

2 Comments(s)

Copy linkTweet thisAlerts:
@SempervivumMay 31.2020 — Please add code tags when posting code: `your code here`

I edited your posting accordingly.

Your PHP code shows the definition of the function only, not the context (connecting to the database, getting the parameter, calling the function, outputting the result). I recommend to test the PHP standalone first, you might change POST to GET temporarily in order to provide the param easily.
Copy linkTweet thisAlerts:
@jrjongauthorJun 07.2020 — thanks sempervivum. [aol mail login](https://aolsigninhelp.com) It worked
×

Success!

Help @jrjong spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.25,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...