$str="select * from user";should be
$str="select * from user where user_name='$user'";晕,你一个问题都发了三遍了....
$str="select * from user where user_name='$user'";晕,你一个问题都发了三遍了....
解决方案 »
- php由于目标机器积极拒绝,无法连接(注意:phpmyadmin完全正常,只有自己写的代码出错)
- html表格边框问题
- URL隐藏转发后PHP SESSION不起用问题
- 怎么在ie下运用ajax正常在火狐下就不行了呢
- 通过html编辑器插入数据出现的怪问题
- 高手来看看!!有关mysql的问题
- 请大家谈一谈php对事务的处理,急!!!
- 千分问题之一:详情请看内容(谁能答对送一千分,up者有分,up三次以上者没分,回答问题除外)
- 我想从array("北京","上海","北京","成都","上海")中取出不相同的值来,该怎么办?
- 新手又有正则问题需要请教!
- 有没有apache的httpd.conf的中文设置说明,我有几个问题
- win2k iis+php怎么作才能正确解释诸如http://url/show.php/hello/who这样的php脚本?
$url="Location: main.php?userid=".$user_id;
/****************/
check-index.php
/****************/<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>CHECKUSER</title>
</head>
<body>
<?
switch($title){
case 1:
?><p><br><br><center>用户注册</center></p>
<form action="check-adduser.php" method="post">
<table width="400" border="1" align="center">
<tr>
<td width="150" align="center">姓名</td>
<td width="250" align="center"><input name="username" type="text" size="20" maxlength="20"></td>
</tr>
<tr>
<td align="center">密码</td>
<td align="center"><input name="password" type="password" size="20" maxlength="20"></td>
</tr>
<tr>
<td align="center"> </td>
<td align="right"><input name="" type="submit" value="注册"><input name="" type="reset"></td>
</tr>
<tr>
<td align="center"> </td>
<td align="center"><a href="check-index.php">返回</a></td>
</tr>
</table>
</form>
<?
break;
case 2:
?>
<p><br><br><center>用户登陆</center></p>
<form action="check-check.php" method="post">
<table width="400" border="1" align="center">
<tr>
<td width="150" align="center">姓名</td>
<td width="250" align="center"><input name="username" type="text" size="20" maxlength="20"></td>
</tr>
<tr>
<td align="center">密码</td>
<td align="center"><input name="password" type="password" size="20" maxlength="20"></td>
</tr>
<tr>
<td align="center"> </td>
<td align="right"><input name="" type="submit" value="登陆"><input name="" type="reset"></td>
</tr>
<tr>
<td align="center"> </td>
<td align="center"><a href="check-index.php">返回</a></td>
</tr>
</table>
</form>
<?
break;
default:
?><br>
<br>
<table width="500" border="1" align="center">
<tr>
<td align="center"><a href="check-index.php?title=1">注册用户</a></td>
<td align="center"><a href="check-index.php?title=2">用户登陆</a></td>
</tr>
</table><?
break;
}
?>
</body>
</html>/********************************//****************/
check-adduser.php
/****************/<?phpinclude("conn.php");$username=$HTTP_POST_VARS[username];
$password=$HTTP_POST_VARS[password];if (empty($username) || empty($password)){
die("Incomplete form");}$connect=mysql_pconnect($host,$dbusername,$dbpassword);
mysql_select_db($database) or die("conn db error");$str="select * from user where username = '$username'";
$result=mysql_query($str);if($row=mysql_fetch_array($result)){
die("This name is been used!");}else{ $password = md5($password);
$query="insert into user set username = '$username',password = '$password'";
mysql_query($query) or die("add data error!");}echo "<HTML>";
echo "<CENTER><BR><BR>regist successfully!</CENTER>";
echo "<META http-equiv=\"refresh\" content =\"2;url=check-index.php\">";
echo "</HTML>";
exit;?>/**************************************//****************/
check-check.php
/****************/<?phpinclude("conn.php");$username=$HTTP_POST_VARS[username];
$password=$HTTP_POST_VARS[password];if (empty($username) || empty($password)){
die("Incomplete form");}$connect=mysql_pconnect($host,$dbusername,$dbpassword);
mysql_select_db($database) or die("conn db error");$str="select * from user where username = '$username'";
$result=mysql_query($str);if($row=mysql_fetch_array($result)){
if (!(md5($password)===$row["password"])){
die("Invalid Password"); } $userid=$row["userid"];}else{
die("User does not exist !"); }$url="Location: check-main.php?userid=".$userid;
header($url);
exit;?>
/***************************//****************/
conn.php
/****************/<?php
$database="test";
$host="localhost";
$dbusername="root";
$dbpassword="";?>
每次程序执行到这个就出错,本来我的密码是和数据库密码是一样的,但是它老是提示
die("Invalid Password"),这是为什么呢,我的password字段是字符型的,用户名可以判断得好,就是密码判断不出,为什么呢,是不是这个if语句有什么问题呢?
username var 20
password var 60 (注意这里。太少了可不行哦:)
<?
switch($title){
case 1:
?>
用这个case语句是用来判断什么的呢?
是不是用来判断用户的级别??
你一般什么时候在线呢,我想向你请教,我一般是晚上才有空,因为白天都要上课,现在我也是在上课,不过是上机课,今晚要下班辅导.希望辅导后能在网上见到你,