免费注册 查看新帖 |

Chinaunix

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

关于isset函数的问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-10-18 12:29 |只看该作者 |倒序浏览
本帖最后由 jgcjsw 于 2011-10-18 12:31 编辑

这个问题搞了我几天都没有搞清楚,如果不加红色部分的内容,newname中不管输入或不输入任何内容,直接点击表单中的Add user按钮,程序
都会执行InsertUser和header函数。这是为什么啊?查了一下$_POST['newname']的直是空的啊
<?php
        include_once 'conn.class.php';
        include_once 'funs.inc.php';
       
        $con=new conn;
        $mysqli=$con->conndb();
       
        if (isset($_POST['Msub']))
        {
                if (!isset($_POST['newname']) || strlen($_POST['newname'])==0)
                {
                        echo "UserName can not be null.<br>";
                        var_dump(isset($_POST['newname']));
                        return ;
                }else{
                        InsertUser("{$_POST['newname']}", "{$_POST['newpass']}",$mysqli);
                        header("location:get_data.php");
                }
        }


?>

////////////以下是表单内容
<html>
        <head>
                <title>User Managerment</title>
                <link rel="stylesheet" type="text/css" href="userManager.css">
        </head>
        <body>
                <form action="userManager.php" method="post">
                        UserName:<input type="text" name="newname"><p>
                        UserPass:<input type="password" name="newpass"><p>
                        <hr>
                        <p>
                        <input type="submit" name="Msub" value="Add user">&nbsp;&nbsp;&nbsp;&nbsp;
                        <input type="reset" name="res" value="Reset">
                </form>
        </body>
</html>

论坛徽章:
1
2015年迎新春徽章
日期:2015-03-04 09:55:28
2 [报告]
发表于 2011-10-18 14:28 |只看该作者
你var_dump一下$_POST就明白了。

论坛徽章:
0
3 [报告]
发表于 2011-10-19 14:54 |只看该作者
这个问题很显,
先了解isseet()和empty() 是怎么回事吧。
还有" || "。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP