开发者

jquery remote validation, what would be the php code?

开发者 https://www.devze.com 2023-03-22 21:46 出处:网络
I am using bassistance validation plugin and I need to check if the email already exists in my database, can someone ple开发者_StackOverflow社区ase provide a sample php code for the serverside portion

I am using bassistance validation plugin and I need to check if the email already exists in my database, can someone ple开发者_StackOverflow社区ase provide a sample php code for the serverside portion of this? i don't simply want to echo true or false, i want the json solution with the message option too...


This doesn't include the database connection stuff, but figured you would not need that? If you do let me know and I'll provide that as well.

<?php

require_once('dbconnection.php');

$email = $_GET['email'];    
mysqli_select_db($conn, $dbname);
$q = "SELECT Email FROM Users WHERE Email= '" . $email . "'";
$r = mysqli_query($conn, $q) or die(mysqli_error());
$totalRows = mysqli_num_rows($r);

if( $totalRows > 0 )
{
    //email already exists in database, return false.
    echo "false";

} else {
    echo "true";
}

mysqli_free_result($r); //close connection

?>

0

精彩评论

暂无评论...
验证码 换一张
取 消