<?php
/*
* Created on 2010-10-31
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
//echo md5(wangbin.WANGBIN)
include("config.php"); if($_POST[submit]){
$username = str_replace(" ","",$POST[username]); //空格的过滤
$sql = "select * from `p_admin` where `username`=.'$username'";
$query=mysql_query($sql);// $sql="SELECT * FROM `p_admin`where `username` ='wangbin'";
// $query=mysql_query($sql);
// $row=mysql_fetch_array($query);
// $us = is_array($row); $us=is_array($row=mysql_fetch_array($query));
$us ? md5($_POST[password].WANFBIN)==$row[password] : FALSE;
}?>
<form action = "" method="post">
用户名:<input type="text" name="username" style="height:23px"/><br/>
密 码:<input type="password" name="password" style="height:23px"/><br/>
验证码:<input type="code" name="code" size=10 style="height:30px"/><img src="code.php">
<br/><br/>
<input type="submit" name="submit" value="登录">
</form>Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\wamp\www\Wb\user.php on line 21
/*
* Created on 2010-10-31
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
//echo md5(wangbin.WANGBIN)
include("config.php"); if($_POST[submit]){
$username = str_replace(" ","",$POST[username]); //空格的过滤
$sql = "select * from `p_admin` where `username`=.'$username'";
$query=mysql_query($sql);// $sql="SELECT * FROM `p_admin`where `username` ='wangbin'";
// $query=mysql_query($sql);
// $row=mysql_fetch_array($query);
// $us = is_array($row); $us=is_array($row=mysql_fetch_array($query));
$us ? md5($_POST[password].WANFBIN)==$row[password] : FALSE;
}?>
<form action = "" method="post">
用户名:<input type="text" name="username" style="height:23px"/><br/>
密 码:<input type="password" name="password" style="height:23px"/><br/>
验证码:<input type="code" name="code" size=10 style="height:30px"/><img src="code.php">
<br/><br/>
<input type="submit" name="submit" value="登录">
</form>Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\wamp\www\Wb\user.php on line 21
<?php
/*
* Created on 2010-10-31
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
//echo md5(wangbin.WANGBIN)
include("config.php"); if($_POST[submit]){
$username = str_replace(" ","",$POST[username]); //空格的过滤
$sql = "select * from `p_admin` where `username`=.'$username'";
$query=mysql_query($sql);// $sql="SELECT * FROM `p_admin`where `username` ='wangbin'";
// $query=mysql_query($sql);
// $row=mysql_fetch_array($query);
// $us = is_array($row); $us=is_array($row=mysql_fetch_array($query));
$us ? md5($_POST[password].WANFBIN)==$row[password] : FALSE;
}?>
<form action = "" method="post">
用户名:<input type="text" name="username" style="height:23px"/><br/>
密 码:<input type="password" name="password" style="height:23px"/><br/>
验证码:<input type="code" name="code" size=10 style="height:30px"/><img src="code.php">
<br/><br/>
<input type="submit" name="submit" value="登录">
</form>
<?php
/*
* Created on 2010-10-31
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
//echo md5(wangbin.WANGBIN)
include("config.php"); if($_POST[submit]){
$username = str_replace(" ","",$POST[username]); //空格的过滤
$sql = "select * from `p_admin` where `username`='$username'";
$query=mysql_query($sql);// $sql="SELECT * FROM `p_admin`where `username` ='wangbin'";
// $query=mysql_query($sql);
// $row=mysql_fetch_array($query);
// $us = is_array($row); $us=is_array($row=mysql_fetch_array($query));
echo $us;
$us ? md5($_POST[password].WANFBIN)==$row[password] : FALSE;
}?>
<form action = "" method="post">
用户名:<input type="text" name="username" style="height:23px"/><br/>
密 码:<input type="password" name="password" style="height:23px"/><br/>
验证码:<input type="code" name="code" size=10 style="height:30px"/><img src="code.php">
<br/><br/>
<input type="submit" name="submit" value="登录">
</form>
这样 echo 怎么没有结果啊!!!
数组不能用echo,用print_r或者var_dump吧,还有你前面有连接数据库的代码在config.php文件吗?
$us=is_array($row=mysql_fetch_array($query));
echo $us;
$us ? md5($_POST[password].WANFBIN)==$row[password] : FALSE; //改为 $row=mysql_fetch_array($query);
$row ? md5($_POST[password].WANFBIN)==$row[password] : FALSE;
改为
$sql = "select * from `p_admin` where `username`='$username'";
去掉username=.'中的.
你一定很猛 、、、 查资料有让我放那个点的啊!!可是 不行, 我改啦!!!可是$us ? md5($_POST[password].WANFBIN)==$row[password] : FALSE;返回的是FALSE 你说是怎么回事啊!!
谢谢啦!!!
把P_admin的单引号去掉
$sql = "SELECT * FROM p_admin WHERE username = '$username'";
首先查看数据库和是否正常连接。
查看有没有p_admin这个数据表。
查看p_admin里有没有username这个字段。
查看p_admin里有没有你想要查询的值。实在不行,你先echo一下sql语句,然后把输出的语句复制到phpmyadmin,在那里再确认一下。看看有什么样的错误提示。然后把那个错误提示再贴出来。