未定义的索引:PHP联系表单中的消息

时间:2015-12-04 21:51:37

标签: php undefined-index

我在移动到新服务器的网站上有一个简单的联系表格,现在他们每天都收到空白的条目。

以下是表单代码:

<?php

$EmailFrom = "info@mywebsite.com";
$EmailTo = "guyf@mywebsite.com";
$Subject = "Website Contact";
$Name = Trim(stripslashes($_POST['Name'])); 
$Company = Trim(stripslashes($_POST['Company'])); 
$Email = Trim(stripslashes($_POST['Email'])); 
$Message = Trim(stripslashes($_POST['Message'])); 

// validation
$validationOK=true;
if (!$validationOK) {
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
  exit;
}

// prepare email body text
$Body = "The following is a contact us form submitted from your website.";
$Body .= "\n";
$Body .= "\n";
$Body .= "NAME:  ";
$Body .= $Name;
$Body .= "\n";
$Body .= "COMPANY:  ";
$Body .= $Company;
$Body .= "\n";
$Body .= "EMAIL:  ";
$Body .= $Email;
$Body .= "\n";
$Body .= "MESSAGE:  ";
$Body .= $Message;
$Body .= "\n";

// send email 
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

// redirect to success page 
if ($success){
  print "<meta http-equiv=\"refresh\"     content=\"0;URL=contactthanks.php\">";
}
else{
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>

以下是我得到的PHP错误,这对我来说没有意义,因为我在这些行上输入了信息。它可能是空白条目吗?

[04-Dec-2015 11:41:09 America/Denver] PHP Notice:  Undefined index: Name in /home6/mywebsite/public_html/contact-f-2/contactengine.php on line 6
[04-Dec-2015 11:41:09 America/Denver] PHP Notice:  Undefined index: Company in /home6/mywebsite/public_html/contact-f-2/contactengine.php on line 7
[04-Dec-2015 11:41:09 America/Denver] PHP Notice:  Undefined index: Email in /home6/mywebsite/public_html/contact-f-2/contactengine.php on line 8
[04-Dec-2015 11:41:09 America/Denver] PHP Notice:  Undefined index: Message in /home6/mywebsite/public_html/contact-f-2/contactengine.php on line 9

思想?

0 个答案:

没有答案