php判断用户名是否存在数据库里 10
$con=mysql_connect($hostname,$username,$password)ordie('连接失败:'.mysql_error());mysql_s...
$con = mysql_connect($hostname,$username,$password) or die('连接失败:'.mysql_error());
mysql_select_db($dbname);
mysql_query('set names utf8');
$sql = "INSERT INTO $dbname (textfield,textfield2,textfield3,textfield4,radiobutton) VALUES('$_POST[textfield]','$_POST[textfield2]', '$_POST[textfield3]','$_POST[textfield4]','$_POST[radiobutton]')";
$sql1="SELECT * from '$dbname' where 'textfield'='$textfield'";
mysql_query("set names gb2312");
$q=@mysql_query($sql1);
$nos=@mysql_num_rows($q);
if( $nos>0){
echo "<script>alert('注册失败');</script>";die;
}
else{
echo "<script>alert('注册成功');</script>";
}
}
为何一直显示注册陈成功,无论怎么改,怎么输入相同的textfield数据结果一样,从我的代码上看,先执行$SQL再执行$SQL1,那么结果不是一定是注册失败的麽? 展开
mysql_select_db($dbname);
mysql_query('set names utf8');
$sql = "INSERT INTO $dbname (textfield,textfield2,textfield3,textfield4,radiobutton) VALUES('$_POST[textfield]','$_POST[textfield2]', '$_POST[textfield3]','$_POST[textfield4]','$_POST[radiobutton]')";
$sql1="SELECT * from '$dbname' where 'textfield'='$textfield'";
mysql_query("set names gb2312");
$q=@mysql_query($sql1);
$nos=@mysql_num_rows($q);
if( $nos>0){
echo "<script>alert('注册失败');</script>";die;
}
else{
echo "<script>alert('注册成功');</script>";
}
}
为何一直显示注册陈成功,无论怎么改,怎么输入相同的textfield数据结果一样,从我的代码上看,先执行$SQL再执行$SQL1,那么结果不是一定是注册失败的麽? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询