我有一个PHP函数,即数据唯一的响应不是,我想用JavaScript调用它。如果电子邮件已经存在,则停止向表单提交,否则表单可以提交。
<?php include'class.php'; ?>
Enter your email: <input type="text" id="email" onblur="myFunction()">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
function myFunction() { $(document).ready(function() {
var x = document.getElementById("email").value;
if(y=0){
alert('already exist');}
});}
</script>
it is presented in a php class file
public function unique($table,$col,$comp){include'db.php';
$query="SELECT count(*) as flag FROM $table where $col='$comp'";
$result = mysqli_query($con,$query);
while($row = mysqli_fetch_array($result)){$flag=$row['flag'];}
if($flag==0){return 0;}else{return 1;}}
答案 0 :(得分:0)
应为if(y==0)
- 您省略了一个等号。为什么你,不是x?它应该是if (x==1)
此外input
缺少价值,我认为这是$flag