2013-01-08 64 views
0

我正在使用這個腳本 http://www.quackit.com/html/codes/html_form_to_email.cfmSendmail表單反饋,變量聲明?

它工作良好的默認。

但我已經增加了一些額外的變量喜歡:

/* 
This next bit loads the form field data into variables. 
If you add a form field, you will need to add it here. 
*/ 
$namn = $_REQUEST['namn'] ; 
$telefonnummer = $_REQUEST['telefonnummer'] ; 
$email_address = $_REQUEST['email_address'] ; 
$comments = $_REQUEST['comments'] ; 

我的問題是我不能設法讓他們在被髮送的電子郵件顯示出來。

我曾嘗試包括他們是這樣的:

mail("$webmaster_email", "Feedback Form Results", 
    $namn, $email, $telefonnummer, $comments, "From: $email_address"); 

這:

mail("$webmaster_email", "Feedback Form Results", 
    $comments, "From: $email_address"); 
    $email, ;) 
    $telefonnummer, :) 

它不工作了,你有什麼想法我做錯了什麼?

回答

0

您的代碼不匹配mail()定義:http://php.net/manual/en/function.mail.php

你應該有:

mail($webmaster_email, "Feedback Form Results", "$namn, $email, $telefonnummer, $comments", "From: $email_address"); 
+0

感謝,這是非常有用的信息!^_^ –

0

mail()功能看看,它接受四個參數

mail($to, $subject, $message, $headers); 

所以你應該改變你的代碼,使它看起來像這樣,考慮到你在添加這些ne的形式中做了一切正確的事情W¯¯領域

$message=$namn.','. $email.','. $telefonnummer.','. $comments; 
mail($webmaster_email, "Feedback Form Results", $message, "From: {$email_address}"); 

也讓你的信息顯示正確的情況下,你可能需要在你的頭(第四參數)一些額外的信息有內部的一些HTML,從php.net看看這個例子

// To send HTML mail, the Content-type header must be set 
$headers = 'MIME-Version: 1.0' . "\r\n"; 
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 

// Additional headers 
$headers .= 'To: Mary <[email protected]>, Kelly <[email protected]>' . "\r\n"; 
$headers .= 'From: Birthday Reminder <[email protected]>' . "\r\n"; 
$headers .= 'Cc: [email protected]' . "\r\n"; 
$headers .= 'Bcc: [email protected]' . "\r\n"; 

// Mail it 
mail($to, $subject, $message, $headers); 
+0

感謝這是非常有用的信息!^_^ –

0

您需要查看PHP mail。你有很多參數。

基本用法是:mail($to, $subject, $message, $additional_headers);

嘗試:

/* 
This next bit loads the form field data into variables. 
If you add a form field, you will need to add it here. 
*/ 
$namn = $_REQUEST['namn'] ; 
$telefonnummer = $_REQUEST['telefonnummer'] ; 
$email_address = $_REQUEST['email_address'] ; 
$comments = $_REQUEST['comments'] ; 

$message = 'namn: ' . $namn . ' telefonnummer: ' . $telefonnummer . ' email_address: ' . $email_address . ' comments: ' . $comments; 

mail($webmaster_email, "Feedback Form Results", $message, "From: $email_address"); 
+0

感謝這是非常有用的信息!^_ ^ –