我試圖做在PHP中一個很簡單的郵件形式,但得到的錯誤:php郵件需要配置才能正常工作嗎?
PHP Notice: Undefined index: in /var/www/html/sites/send_contact.php on line 10, referer: http://example.com/contact2.php
我的PHP文件看起來像這樣:
<?php // send_contact.php
// Contact subject
$subject =$_POST["$subject"];
// Details
$message=$_POST["$detail"];
// Mail of sender
$mail_from=$_POST["$customer_mail"];
// From
$name2=$_POST["$name2"];
$header="From: $mail_from\r\n";
// Enter your email address
$to="[email protected]";
$send_contact=mail($to,$subject,$message,$header);
// Check, if message sent to your email
// display message "We've recived your information"
if($send_contact){
echo "We've recived your contact information";
}
else {
echo "ERROR";
}
?>
如果您的字段被命名爲subject,那麼您可以鍵入$ _POST [「subject」]。如果您希望$ _POST中的值存儲在$ subject中,請使用$ _POST [$ subject]。 – 2009-11-14 22:39:06
以防萬一:一旦這個問題解決了,請務必在投入生產之前進行一些輸入清理...... http://www.phpbuilder.com/columns/ian_gilfillan20060412.php3 – grossvogel 2009-11-14 23:22:35