文件4、(b.php)代码如下: include "conn.php"; if(isset($_POST['sub'])){ $sql = "insert into user(name) value ($_POST['name'])"; $result = mysql_query($sql); if($result){ echo "成功!"; } } ?>
不知道楼主用过jquery没有,如果用过或者想用的话我可以给详细方案。
function check(){var name=$("#name").val();$.post("checkUser.php",{name:name},function(result){ if(result==1){ alert('已经存在用户名'); return false; }});}
checkUser.php
$sql="select * from user where name=".$_POST['name'];$resut=mysql_query($sql);if($result){ echo 1;exit;}
得用jquery post和php很好解决这个,现在很多注册页面都是这样做!
感谢LS各位大虾的帮助,问题解决了。我用的是Ajax。
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn