2013-04-09 154 views
1

我遇到了另一個網站的PHP Formemail問題。PHP Formemail未顯示電話號碼或電子郵件地址

因此,無論何時發佈測試表格,我都會填寫每個字段,但我只會獲取名稱,興趣和消息。該電子郵件應該顯示在電子郵件中與其他字段,並作爲發件人,它顯示爲既不,也不顯示電話。這裏是PHP代碼:

<?php 
$adminemail = '[email protected]'; 

$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 = '[email protected]'; 
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:我嘗試​​在HTML表單字段中添加id =和value =,但那完全沒有。它仍然只返回名稱,興趣和消息,並且電子郵件顯示它來自[email protected]

謝謝!

回答

1

它沒有顯示,因爲它被寫爲<input name-"Email" type="text">而不是<input name="Email" type="text">。作爲一個建議,你爲什麼不把它寫成<input type="email" name="Email">

+0

Ahahahahahaha!哦,我的天啊!!!我不能相信我錯過了!我沒有注意到這一切。我一直在看這段代碼,看看這段代碼,試圖找出它的錯誤,這是一個愚蠢的錯誤,對我來說是完全不可見的。 – AceofHearts 2013-04-09 18:37:27

+0

非常感謝你。我感到非常愚蠢,但鬆了一口氣,就像那樣簡單。現在,你永遠在我心中。 – AceofHearts 2013-04-09 18:38:05

+1

我很高興我可以對你有所幫助,而且......沒關係......這就是爲什麼有人在一段時間內檢查你的代碼總是有用的。我們傾向於盲目自己,認爲我們的代碼是「完美」的。每次都會發生:P – 2013-04-09 18:40:58

相關問題