欧卡2中文社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

需要三步,才能开始

只需两步,慢速开始

玩欧卡就用莱仕达V10方向盘欧卡2入门方向盘选莱仕达V9莱仕达折叠便携游戏方向盘支架欢迎地图Mod入驻
查看: 2584|回复: 1
收起左侧

PHP中提示Notice: Undefined index: submit in

[复制链接]
知行 发表于 2012-8-24 14:20 | 显示全部楼层 |阅读模式
PHP中提示Notice: Undefined index: submit in
if($_POST['submit']) {
        $db = mysql_connect($dbhost, $dbuser, $dbpassword);
        mysql_select_db($dbdatabase, $db);

        $sql = "INSERT INTO myblog_comments(blog_id, dateposted, name, comment) VALUES(" . $validentry . ", NOW(), '" . $_POST['name'] . "', '" . $_POST['comment'] . "');";
        mysql_query($sql);
        header("Location: http://". $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']."?id=" . $validentry);
}
解决办法有两个:

1: if($_POST['submit']) 加一个判断条件,改为=>
if(isset($_POST['submit']) && $_POST['submit'])

2: 在开头加上
error_reporting(E_ALL & ~E_NOTICE); // 这句话表示提示除去 E_NOTICE 之外的所有错误信息
因为post数组是个空的array,而代码中的这种方法适用于的是提交以后。
 楼主| 知行 发表于 2012-8-24 14:25 | 显示全部楼层
        if(isset($error)&&$error == 1) {
                header("Location: " . $config_basedir);
        }
这段代码一样的情况

联系我们|手机版|欧卡2中国 ( 湘ICP备11020288号-1 )

GMT+8, 2024-5-14 01:00 , Processed in 0.037587 second(s), 7 queries , Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表