免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 2389 | 回复: 13
打印 上一主题 下一主题

关于登录问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-10-24 12:44 |只看该作者 |倒序浏览
初学,请大家都指点,我做两个页面,login.php,check.php,在login.php里输入用户名和密码,提交给check.php进行判断,如果数据库中有此用户则进入mai.php,否则进入login.php.
每次输入完用户名和密码,提交后都不能跳转到指定的页面

login.php


            <TABLE>
              <FORM name=form_logon onSubmit="return Check(this)"
              action=Check.php method=post>
              <TR>
                <TD>管理员: </TD>
                <TD><INPUT maxLength=20 name=user type=text></TD></TR>
              <TR>
                <TD>密&nbsp;&nbsp码: </TD>
                <TD><INPUT type=password maxLength=20 name=password></TD></TR>
              <TR align=middle>
      
                <TD><INPUT type=image height=19 alt=登录 width=57 src="3E-platform.files/denglu_1.gif" border=0 name=imageField>
                           </TD></TR></FORM></TABLE>

check.php


<?php
$user=$_POST['user'];
$passowrd=$_POST['password'];
if(isset($user) && strlen($user) > 0)
{
mysql_connect("localhost", "root", "dscl521");
mysql_select_db("school") or die ("不能连接到数据库!");

$strSql="select * from user where user='$user' and password='$password'";
$result=mysql_query($strSql);// or die("读取数据库出现错误!");
$num=mysql_num_rows($result);

if($num > 0)
{
echo "<center>登录成功!</center><br>";
require("mainad.php");
}
else
{
echo "<center><font color=red>登录失败!请检查用户名和密码!</font></center><br>";
require("login.php");
}
}
?>

论坛徽章:
0
2 [报告]
发表于 2006-10-24 13:04 |只看该作者
$strSql="select * from user where user=$user and password=$password";
或者
$strSql='select * from user where user='.$use.' and password='.$password;


if($num > 0)
{
echo "<center>登录成功!</center><br>";
header("location:mainad.php");
}...

?>

[ 本帖最后由 yueliangdao0608 于 2006-10-24 13:06 编辑 ]

论坛徽章:
0
3 [报告]
发表于 2006-10-24 13:37 |只看该作者
onSubmit="return Check(this)" ?
把check拿出来看看

论坛徽章:
0
4 [报告]
发表于 2006-10-24 14:52 |只看该作者
利用断点测试!跟跟数据在查查手册就OK啦

论坛徽章:
0
5 [报告]
发表于 2006-10-24 15:11 |只看该作者
非常感谢大家这么热情的支持,check我已经贴在版头了;
按照yueliangdao0608给的方法,做了修改,但是现在无论输入什么用户名和密码,就是进不了后台

论坛徽章:
0
6 [报告]
发表于 2006-10-24 16:04 |只看该作者
$passowrd=$_POST['password'];

………………

论坛徽章:
0
7 [报告]
发表于 2006-10-24 16:07 |只看该作者
下面是修改后的check.php

<html><head><title>后台管理</title></head><body>
<?php
$user=trim($_POST['user']);
$passowrd=trim($_POST['password']);
if(isset($user) && strlen($user) > 0)
if(isset($user) && strlen(trim($user)) > 0)
{
$lnk = mysql_connect("localhost", "root", "dscl521");
mysql_select_db("school",$lnk) or die ("不能连接到数据库!");
//判断用户名和密码是否在正确
$strSql='select * from user where user='.$use.' and password='.$password;
$result=mysql_query($strSql);// or die("读取数据库出现错误!");
$num=mysql_num_rows($result);

if($num > 0)
{
header("location:mainad.php");
}
else
{
header("location:login.php");
}
}
?>
</body></html>

论坛徽章:
0
8 [报告]
发表于 2006-10-24 16:40 |只看该作者
原帖由 dscl521 于 2006-10-24 18:07 发表
下面是修改后的check.php

<html><head><title>后台管理</title></head><body>
<?php
$user=trim($_POST['user']);
$passowrd=trim($_POST['password']);
if(isset ...


看来你没看到上面的回复。

$passowrd=$_POST['password'];

………………

论坛徽章:
0
9 [报告]
发表于 2006-10-24 21:08 |只看该作者
路过,楼主跟我一样有趣

论坛徽章:
0
10 [报告]
发表于 2006-10-24 22:40 |只看该作者
原帖由 geel 于 2006-10-24 16:04 发表
$passowrd=$_POST['password'];

………………


眼真利,羡慕,俺视力现在基本“伸手不见五指”级别。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP