php检测用户名的问题

来源:百度知道 编辑:UC知道 时间:2024/07/02 05:29:34
注册页面:
<input type="text" name="user" size="20" maxlength="50"/>
<input type="button" name="Submit1" value="检测用户名"onclick="window.open('login.php');" />

login.php页面:

<?php
$user1=$_POST[user];
include "../config.php";
$sql_search=mysql_query("select * from login where user='$user1'");
$info=mysql_fetch_array($sql_search);
$user2=$info[user];
if($user1==$user2){
echo "<script>alert('用户名已被注册');history.back();</script>";
}else{
echo "<script>alert('恭喜您,此用户名可以注册');history.back();</script>";
}
?>
当我点‘检测用户名’时,不管输入什么用户名都是跳出已被注册,查了下,原来是user的值没传到login.php里。。请问该怎么传USER的值,或还有没别的方法检测。。越详细越好!!!回答好的追加分!!!

表单应该写在form里边吧。
<form action="login.php" method="post">
<input type="text" name="user" size="20" maxlength="50"/>
.....
</form>
另外login.php里边应该是这样写的$user1=$_POST['user'];
可以试一下
祝你成功

基本HTML语法没学好
<form method=post action="login.php">
<input type="text" name="user" size="20" maxlength="50"/>
</form>