1

我在另一个网站上再次遇到 PHP Formemail 问题。

因此,每当我发布测试表时,我都会填写每个字段,但我只会得到姓名、兴趣和信息。该电子邮件应该在电子邮件中显示其余字段,并且作为发件人,它既不显示,电话也不显示。这是PHP代码:

<?php
$adminemail = 'info@info.com';

$controlvars = ' thankspage submitter ccsubmitter messagetosubmitter ';
$messagetoadmin = $_POST['Name'] ." has sent you the following message:


";

 else $messagetosubmitter = $_POST['messagetosubmitter'];

while(list($key, $value) = each($_POST))
{
 if (!stristr($controlvars, ' '. $key .' '))
 {
  $messagetoadmin .= $key .': '. $value .'

';
  $messagetosubmitter .= $key .': '. $value .'

';
 }
} 
$submitter = $_POST['Email'];
if ($submitter == '') $submitter = 'anon@anon.com';
if (strstr($submitter, "\n") || strlen($submitter) > 50) die("Begone, foul spammer.");


mail($adminemail, 'Message from site: '. stripslashes($_POST['subject']),     stripslashes($messagetoadmin), 'From: '. $submitter);

if ($_POST['ccsubmitter'] == 'yes')
{
 mail($Email, 'Message from site: '. stripslashes($_POST['subject']),     stripslashes($messagetosubmitter), 'From: '. $adminemail);
}
if ($autoresponse != '')
{
 $body = geturl($autoresponse);
 mail($Email, 'Re: '. stripslashes($_POST['subject']), stripslashes($body), 'From: '.     $adminemail);
}
header('Location: '. $_POST['thankspage']);
// just in case redirect doesn't work
die('<meta http-eqiv="refresh" content="0;url='. $_POST['thankspage'] .'">');

if (!function_exists('geturl'))
{
function geturl($url)
{
 if (extension_loaded('curl')) 
 {
    $user_agent = 'Mozilla/4.0 (compatible; MSIE 6.02; PHP)';
   $ch = curl_init(); 
   curl_setopt ($ch, CURLOPT_URL, $url); 
   curl_setopt ($ch, CURLOPT_USERAGENT, $user_agent); 
   curl_setopt ($ch, CURLOPT_HEADER, false); 
   curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true); 
   curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 15);  // timeout after 5 seconds
   curl_setopt ($ch, CURLOPT_TIMEOUT, 15);  // timeout after 5 seconds   
   curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, true); 
   $result = curl_exec ($ch); 
   curl_close ($ch); 
// curl_error($ch); // for debugging
   return $result;  
 }

 if (version_compare("4.3.0", phpversion(), "<"))
 { 
  $filecontents = @file_get_contents($url);
 }
 else
 {
  $fd = @fopen($url, 'rb');
  $filecontents = "";
  do 
  {
   $data = @fread($fd, 8192);
   if (strlen($data) == 0) 
   {
    break;
   }
   $filecontents .= $data;
  } while(true); 
  @fclose ($fd);
 }
 return $filecontents;
}
}

?>

这是表单的 HTML:

<form name="Contact" id="Contact" method="post" action="formemail.php"     onsubmit="return ValidateContactForm();">
            <input type="hidden" name="thankspage"     value="thankyou.html">
                <input type="hidden" name="ccsubmitter"     value="yes">

                <label><span>Name: *</span>
                    <input name="Name" type="text" >
                </label>
                <label><span>Email: *</span>
                    <input name-"Email" type="text" >
                </label>
                <label><span>Phone:</span>
                    <input name-"Phone" type="text" >
                </label>
                <label><span>Interests:</span>
                    <input name="interests" type="text" >
                </label>
                <label><span>Message:</span></label>
                    <label><textarea name="message"      cols="30"     rows="10" ></textarea>
                </label>
                <input type="submit" value="">
            </form>

任何帮助都将不胜感激并永远记住。预先感谢您的好意!

ETA:我尝试​​将 id= 和 value= 添加到 HTML 表单字段,但这完全没有任何作用。它仍然只返回姓名、兴趣和消息,电子邮件显示它来自 anon@anon.com。

谢谢!

4

1 回答 1

1

它没有显示,因为它被写成<input name-"Email" type="text">而不是<input name="Email" type="text">. 作为一个建议,你为什么不把它写成<input type="email" name="Email">

于 2013-04-09T18:29:37.803 回答