2010-03-13 176 views
1

嘿,不知道爲什麼這個sint工作,但消息被髮送爲「0」。我認爲,電子郵件字段是什麼原因造成發送郵件php

<?php 
if ($_POST['check'] == 'checked'){ 
     header("location: /nospamplease.html"); 
     exit(); 
} 

$name = $_POST['name']; 
$email = $_POST['email']; 
$phone = $_POST['phone']; 
$date = $_POST['date']; 
$children = $_POST['children']; 
$hot = $_POST['hot']; 
$comments = $_POST['comments']; 

/*echo $name; 
echo $email; 
echo $phone; 
echo $date; 
echo $children; 
echo $hot; 
echo $comments;*/ 

if($name == "" || $email == "" || $phone == "" || $date == "" || $children == "" || $hot == "" || $comments == ""){ 
    echo "Please ensure all fields were filled out!"; 
    exit(); 
}else{ 
    $to = "######"; 
    $subject = "Birthday enquiry"; 
    $message = "Name: ".$name; 
    $message += "Email: ".$email; 
    $message += "Phone: ".$phone; 
    $message += "Date: ".$date; 
    $message += "Children: ".$children; 
    $message += "Hot or cold: ".$hot; 
    $message += "Comments: ".$comments; 
    //echo $message; 
    if(mail($to, $subject, $message)){ 
     echo "Thank you for your enquiry, we will contact you within the next 24 hours! <br /> Click <a href='###'> here</a> to go back to the website!"; 
    }else{ 
     echo "There was an error, contact us directly: <a href='mailto:##'>email</a>"; 
    } 
} 
?> 

我附和了變數,他們都越來越精細發佈

謝謝你們

回答

4

不能使用+來連接字符串在PHP中。使用.

$message .= "Email: ".$email; 
+0

啊哈當然,這個月一直在用太多的java:S歡呼芽 – user195257 2010-03-13 15:45:19