注意:未定义的索引:第12行的/var/www/mailer.php中的主题注意:未定义的索引:第13行的/var/www/mailer.php中的消息注意:未定义的索引:从第14行的/var/www/mailer.php注意:注意:未定义的索引:第15行中的/var/www/mailer.php中的verifier。注意:未定义的索引:tntcon在/var/www/mailer.php上线23没有收到任何变量,当前页不能被直接访问PHP - “Notice:Undefined index”error
下面是代码
<?php
ini_set('display_errors',1);
error_reporting(E_ALL|E_STRICT);
// -----------------------------------------
// The Web Help .com
// -----------------------------------------
// remember to replace [email protected] with your own email address lower in this code.
// load the variables form address bar
$subject = $_POST["subject"];
$message = $_POST["message"];
$from = $_POST["from"];
$verif_box = $_POST["verif_box"];
// remove the backslashes that normally appears when entering " or '
$message = stripslashes($message);
$subject = stripslashes($subject);
$from = stripslashes($from);
// check to see if verificaton code was correct
if(md5($verif_box).'a4xn' == $_COOKIE['tntcon']){
// if verification code was correct send the message and show this page
mail("[email protected]", 'TheWebHelp.com Form: '.$subject, $_SERVER['REMOTE_ADDR']."\n\n".$message, "From: $from");
// delete the cookie so it cannot sent again by refreshing this page
setcookie('tntcon','');
} else if(isset($message) and $message!=""){
// if verification code was incorrect then return to contact page and show error
header("Location:".$_SERVER['HTTP_REFERER']."?subject=$subject&from=$from&message=$message&wrong_code=true");
exit;
} else {
echo "no variables received, this page cannot be accessed directly";
exit;
}
?>
*(tipp)*使用'error_reporting(-1);'会显示每个可能的错误,即使在未来的PHP版本中添加了新的级别和常量时也是如此。 – Gordon 2010-10-29 15:13:42
有没有听说过?:D第二,这些是通知的 - 没有错误,你可能试图访问部分$ _POST,这不存在 – Hannes 2010-10-29 15:15:00