2010-02-04 42 views
0

您好任何人都可以建議一個PHP表單的快速形式腳本? 我從telepro下面生成了一個,修改了html和電子郵件了一下,但我得到這個錯誤的複選框php來形成腳本?語法錯誤意外

解析錯誤:語法錯誤,意外的'='在/home/inn.co.uk/public /mailer.php線14

感謝您的幫助

問候 朱迪

 <form method="POST" action="contact.php"> 

<div class="form-field"> 
    <input type="text" name="Name" onFocus="if(this.value=='Name')this.value='';" value="Name"> 
</div> 
<div class="form-field"> 
    <input type="text" name="Telephone" onFocus="if(this.value=='Telephone')this.value='';" value="Telephone"> 
</div> 
<div class="form-field"> 
    <input type="text" name="Timetocall" onFocus="if(this.value=='Time to call')this.value='';" value="Time to call"> 
    </div> 
<div class="form-field"> 
       <ul class="tickboxes"> 
             <li>Do you agree to our<br/><a href="terms-and-conditions.html">Terms of Business </a><input type="checkbox" name="DoyouagreetoourTermsofBusiness?" value="Yes" /></li></ul></div> 




      <div class="button"> 
       <input type="image" src="images/submit.jpg" value="" name="submit"> 
      </div> 
    </form> 

<?php 
// Website Contact Form Generator 
// http://www.tele-pro.co.uk/scripts/contact_form/ 
// This script is free to use as long as you 
// retain the credit link 

// get posted data into local variables 
$EmailFrom = "[email protected]"; 
$EmailTo = "[email protected]"; 
$Subject = "New enquiry"; 
$Name = Trim(stripslashes($_POST['Name'])); 
$Telephone = Trim(stripslashes($_POST['Telephone'])); 
$Timetocall = Trim(stripslashes($_POST['Timetocall'])); 
$DoyouagreetoourTermsofBusiness? = Trim(stripslashes($_POST['DoyouagreetoourTermsofBusiness?'])); 

// validation 
$validationOK=true; 
if (Trim($Name)=="") $validationOK=false; 
if (Trim($Telephone)=="") $validationOK=false; 
if (Trim($Timetocall)=="") $validationOK=false; 
if (Trim($DoyouagreetoourTermsofBusiness?)=="") $validationOK=false; 
if (!$validationOK) { 
    print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; 
    exit; 
} 

// prepare email body text 
$Body = ""; 
$Body .= "Name: "; 
$Body .= $Name; 
$Body .= "\n"; 
$Body .= "Telephone: "; 
$Body .= $Telephone; 
$Body .= "\n"; 
$Body .= "Timetocall: "; 
$Body .= $Timetocall; 
$Body .= "\n"; 
$Body .= "DoyouagreetoourTermsofBusiness?: "; 
$Body .= $DoyouagreetoourTermsofBusiness?; 
$Body .= "\n"; 

// send email 
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); 

// redirect to success page 
if ($success){ 
    print "<meta http-equiv=\"refresh\" content=\"0;URL=ok.htm\">"; 
} 
else{ 
    print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; 
} 
?> 

回答

2

您在變量名稱中使用問號。這是行不通的。

有關命名約定,請參閱PHP Manual on variables

通過

$DoyouagreetoourTermsofBusiness 

更換

$DoyouagreetoourTermsofBusiness? 

,它會正常工作。

+0

還要替換表單中的名稱值。 – 2010-02-04 11:58:57

+0

感謝Adam,我做了你所說的一切,但是當我點擊發送時,即使我勾選了複選框,我也會收到此消息 - 您必須同意我們的商業條款。請點擊此處返回表格 – 2010-02-04 14:06:23

+0

您是否也將其從stripslashes()調用中刪除? – 2010-02-04 15:00:08