PHP 验证用户名是否存在
<?php/**Createdon2012-1-17**Tochangethetemplateforthisgeneratedfilegoto*Window-Prefer...
<?php
/*
* Created on 2012-1-17
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
error_reporting(0);
include("dblink.php");
if($_POST["submit"]=="登录"){
$user=$_POST[user];
$psw=$_POST[psw];
$sql="select * from userlist where 'user'='$user'";
$us=mysql_query($sql);
$us=mysql_fetch_row($us);
if(is_array($us)){
echo "cunzai";
}
else echo "bucunzai";
}
?>
<form name="login" method="post" >
<table>
<tr>
<td>用户名:<input name="user" type="text" ></td></tr>
<tr>
<td>密 码:<input name="psw" type="password" ><p>
<input name="submit" type="submit" value="登录" >
<input name="registe" type="button" value="新用户注册" onclick="location.href='register.php';" >
</td>
</tr>
</table></form>
不管输入什么用户名都显示了不存在,不晓得错在哪里,初学,求指教!谢谢! 展开
/*
* Created on 2012-1-17
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
error_reporting(0);
include("dblink.php");
if($_POST["submit"]=="登录"){
$user=$_POST[user];
$psw=$_POST[psw];
$sql="select * from userlist where 'user'='$user'";
$us=mysql_query($sql);
$us=mysql_fetch_row($us);
if(is_array($us)){
echo "cunzai";
}
else echo "bucunzai";
}
?>
<form name="login" method="post" >
<table>
<tr>
<td>用户名:<input name="user" type="text" ></td></tr>
<tr>
<td>密 码:<input name="psw" type="password" ><p>
<input name="submit" type="submit" value="登录" >
<input name="registe" type="button" value="新用户注册" onclick="location.href='register.php';" >
</td>
</tr>
</table></form>
不管输入什么用户名都显示了不存在,不晓得错在哪里,初学,求指教!谢谢! 展开
2012-02-03
展开全部
//判断用户名是否已经存在
$query="select * from $table_name where username='$username1'";
$result=mysql_query($query);
$row=mysql_fetch_array($result);
if($row["username"]==$username1){
.............................
else
......................
}
$query="select * from $table_name where username='$username1'";
$result=mysql_query($query);
$row=mysql_fetch_array($result);
if($row["username"]==$username1){
.............................
else
......................
}
追问
可是这回变成输什么都存在了啊
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询