2012-10-25 96 views
-2

你能幫我解決一個錯誤:語法錯誤,C:\ xampp \ htdocs \ xampp \ form-to-email.php中的文件意外結束第42行想,如果你可以用這個我很困惑helpme ...解析錯誤:語法錯誤,意外的文件結尾

<?php { 
    if(!isset($_POST['submit'])) 
    { 
    //This page should not be accessed directly. Need to submit the form. 
    echo "error; you need to submit the form!"; 

    $name = $_POST['name']; 
    $attend = $_POST['attend']; 
    $email = $_POST['email']; 
    $phone = $_POST['phone']; 
    $office = $_POST['office']; 
    $starter = $_POST['starter']; 
    $mainmeal = $_POST['mainmeal']; 
    $specialdietaryrequirements = $_POST['specialdietaryrequirements']; 
    $otherdietaryrequirements = $_POST['otherdietaryrequirements']; 
    $nameofguest = $_POST['nameofguest']; 
    $starterguest = $_POST['starterguest']; 
    $mainmealguest = $_POST['mainmealguest']; 
    $guestspecialdietaryrequirements = $_POST['guestspecialdietaryrequirements']; 
    $guestotherdietaryrequirements = $_POST['guestotherdietaryrequirements']; 
    //email body 
    $email_from = '[email protected]'; 
    $email_subject = "Christmas Part Submission"; 
    $email_body = "You have received a new message from the user $name.\n". 
    "Are you attending: $attend \n". 
    "Email address from the person: $email \n". 
    "Contact number: $phone \n". 
    "Office: $office \n". 
    "Starter: $starter \n". 
    "Main Meal: $mainmeal \n". 
    "Special Dietary Requirements: $specialdietaryrequirements \n". 
    "Other Dietary Requirements: $otherdietaryrequirements \n". 
    "Name of Guest: $nameofguest \n". 
    "Guest Starter: $starterguest \n". 
    "Guest Main Meal: $mainmealguest \n". 
    "Guest Special Dietary requirements: $guestspecialdietaryrequirements \n". 
    "Guest other Dietary requirements: $guestotherdietaryrequirements \n". 
    // who it is being sent too (edit this) 
    $to = "[email protected]"; 
    $headers = "From: $email_from \r\n"; 
    mail($to,$email_subject,$email_body,$headers); 
    { ?> 
+0

缺少','在定義行' 「客戶其他飲食要求:$ guestotherdietaryrequirements \ n」 個.' –

+1

線42 ...取代''{用'}' –

+0

還刪除那條線上的'.' –

回答

0

通過它的外觀,你忘了關閉您的if語句和任何一個地方開始。 嘗試在結束與

} 
} 
0

最後一個左大括號替換

{ 

在文件的結尾必須改變到關閉一個

1

替換此:

<?php { 
if(!isset($_POST['submit'])) 
{ 

<?php 
if(!isset($_POST['submit'])) 
{ 

{在你的長代碼的結尾應該是}

+0

它現在的效果很好,現在我只能看到一個空白頁面,它不會發送到電子郵件。比kyou的幫助 – stoneseraphim

+0

您是否有正確的電子郵件地址? $ to =「[email protected]」; – adrianTNT

0

第一線僅

<?php 

沒有{

最後一行: 必須關閉標籤IF不打開它!

}

<?php  
    if(!isset($_POST['submit'])) 
    { 
    ... 
    mail($to,$email_subject,$email_body,$headers); 
    } 
?> 
相關問題