免费注册 查看新帖 |

Chinaunix

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

php初级问题,请大家帮忙 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2003-05-28 12:06 |只看该作者 |倒序浏览
我写了一段代码如下:
<HTML>;
        <HEAD>;
                <TITLE>;管理员登录</TITLE>;
        </HEAD>;
        <BODY alink="#FF0000" link="#000099" vlink="#CC6600" topmargin="8" leftmargin="0" bgColor="#FFFFFF">;
        
;

        <?php
        if($mname!=""
        {
                mysql_connect("localhost", "root", "";
                mysql_select_db("main_db" or die("不能连接到数据库!";

                $strSql="select * from manager where mname='$mname' and pwd='$password'";
                $result=mysql_query($strSql);
                $num=mysql_numrows($result);
                if($num>;0)
                {
                        echo "<center>;登录成功</center>;<br>;";
                }

                }
                else echo "<center>;登录失败! 请检查管理员名和密码</center>;<br>;";
        }
        else
        {
                echo "<center>;请输入管理员名和密码登录!</center>;";
        ?>;

        <FORM action="<?php print ($PHP_SELF);?>;" method="post">;
        <table cellspacing=0 bordercolordark=#FFFFFF width="60%" bordercolorlight=#000000 border=1 align="center" cellpadding="2">;
                <tr bgcolor="#6b8ba8 style="color:FFFFFF">;
                  <td width="100%" align="center" valign="bottom" height="19" colspan="3">;管理员登录</td>;
                </tr>;
                <tr>;
                  <td width="30%" align="center">;管理员名:</td>;
                  <td width="70%" align="center">;<input type="text" name="mname" size="20" maxsize="20">;</td>;
                </tr>;
                <tr>;
                 <td width="30%" align="center">;密    码:</td>;
                 <td width="70%" align="center">;<input type="password" name="password" size="20" maxsize="20">;</td>;
                </tr>;
                <tr>;
                  <td width="100%" align="center" colspan="2">;<input type="submit" value="登录">;</td>;
                </tr>;
        </table>;
        </FORM>;
        <?php
                }
        ?>;
        </BODY>;
</HTML>;

我在按“登录”提交以后却无法拿到mname和password的值,请问为什么。

还有,就是如果我想实现针对不同的mname调用不同的其它php文件,同时要有变量值传到该php中,该如何实现。

请大家帮忙。不胜感激。

论坛徽章:
0
2 [报告]
发表于 2003-05-28 12:10 |只看该作者

php初级问题,请大家帮忙

可能是你的全局变量没有打开


; - register_globals = Off         [Security, Performance]
;     Global variables are no longer registered for input data (POST, GET, cookies,
;     environment and other server variables).  Instead of using $foo, you must use
;     you can use $_REQUEST["foo"] (includes any variable that arrives through the
;     request, namely, POST, GET and cookie variables), or use one of the specific
;     $_GET["foo"], $_POST["foo"], $_COOKIE["foo"] or $_FILES["foo"], depending
;     on where the input originates.  Also, you can look at the
;     import_request_variables() function.
;     Note that register_globals is going to be depracated (i.e., turned off by
;     default) in the next version of PHP, because it often leads to security bugs.
;     Read http://php.net/manual/en/security.registerglobals.php for further
;     information.     

把 register_globals = Off         改为register_globals = On试试看

论坛徽章:
0
3 [报告]
发表于 2003-05-28 12:13 |只看该作者

php初级问题,请大家帮忙

打开后要重启apache吗?

论坛徽章:
0
4 [报告]
发表于 2003-05-28 12:31 |只看该作者

php初级问题,请大家帮忙

[quote]原帖由 "yanger"]打开后要重启apache吗?[/quote 发表:
     


是的     

但不建意使用"On"

取POST数据可以用$_POST["var"]

取GET数据可以用$_GET["var"]

取SERVER数据可以用$_SERVER["var"]

取SESSION数据可以用$_SESSION["var"]

取FILE数据可以用$_FILE["var"]

这些就够用了

论坛徽章:
0
5 [报告]
发表于 2003-05-28 12:31 |只看该作者

php初级问题,请大家帮忙

第一个问题已经解决,多谢。
再请问第二个问题如何解决,即:
当不同类型的管理员登录时,调用不同的php,且需要有变量传给该php.

请高手指点.

论坛徽章:
0
6 [报告]
发表于 2003-05-28 12:42 |只看该作者

php初级问题,请大家帮忙

谢谢,我的确是象你所说的那么引用的。不过还有一个问题,我引用后,当我重新load这个php时,哪个mname的值还是有的,怎么样可以将其清掉
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP