2010-02-04 7 views
0

안녕하세요 누구든지 PHP 양식에 대한 빠른 양식 스크립트를 제안 할 수 있습니까? telepro에서 아래 코드를 생성하고 html과 이메일을 조금 수정했지만 체크 박스에서이 오류가 발생했습니다.스크립트를 형성하는 PHP? 구문 오류 예기치 않은

구문 분석 오류 : 예기치 않은 '='in /home/inn.co.uk/public 당신의 도움이

감사 14

덕분 줄에 /mailer.php 주디

 <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

또한 양식의 이름 값을 대체하십시오. –

+0

감사합니다 아담, 나는 당신이 말한 모든 것을했습니다. 그러나 체크 박스를 체크 했는데도이 메시지를 보냅니다. 우리의 사업 조건에 동의해야합니다. 양식을 반환하려면 여기를 클릭하십시오 –

+0

stripslashes() 호출에서도 제거 했습니까? –

관련 문제