2013-02-01 2 views
0

방금 ​​새로운 PHP 문의 양식을 설치했지만 작동하지 않습니다. 나는 이미 그것을 고치려고했지만 어떻게 고칠 수 있는지 알 수 없다. 누군가 그것을 살펴보고 고칠 수 있습니까? PHP 코드 :처음 설치시 PHP 문의 양식이 작동하지 않습니다.

 $to = '[email protected]'; 
     $subject = 'Contact'; 
     $contact_submitted = 'Your message has been sent.'; 


     function email_is_valid($email) { 
     return preg_match('/^[A-Z0-9._%+-][email protected][A-Z0-9.-]+\.[A-Z]{2,4}$/i',$email); 
     } 
     if (!email_is_valid($to)) { 
     echo '<p style="color: red;">You must set-up a valid (to) email address before this contact page will work.</p>'; 
     } 
     if (isset($_POST['contact_submitted'])) { 
     $return = "\r"; 
     $youremail = trim(htmlspecialchars($_POST['your_email'])); 
     $yourname = stripslashes(strip_tags($_POST['your_name'])); 
     $yourmessage = stripslashes(strip_tags($_POST['your_message'])); 
     $contact_name = "Name: ".$yourname; 
     $message_text = "Message: ".$yourmessage; 
     $user_answer = trim(htmlspecialchars($_POST['user_answer'])); 
     $answer = trim(htmlspecialchars($_POST['answer'])); 
     $message = $contact_name . $return . $message_text; 
     $headers = "From: ".$youremail; 
     if (email_is_valid($youremail) && !eregi("\r",$youremail) && !eregi("\n",$youremail) && $yourname != "" && $yourmessage != "" && substr(md5($user_answer),5,10) === $answer) { 
      mail($to,$subject,$message,$headers); 
      $yourname = ''; 
      $youremail = ''; 
      $yourmessage = ''; 
      echo '<p style="color: blue;">'.$contact_submitted.'</p>'; 
     } 
     else echo '<p style="color: red;">Please enter your name, a valid email address, your message and the answer to the simple maths question before sending your message.</p>'; 
     } 
     $number_1 = rand(1, 9); 
     $number_2 = rand(1, 9); 
     $answer = substr(md5($number_1+$number_2),5,10); 
    ?> 
    <form id="contact" action="contact.php" method="post"> 
     <div class="form_settings"> 
     <p><span>Name</span><input class="contact" type="text" name="your_name" value="<?php echo $yourname; ?>" /></p> 
     <p><span>Email Address</span><input class="contact" type="text" name="your_email" value="<?php echo $youremail; ?>" /></p> 
     <p><span>Message</span><textarea class="contact textarea" rows="5" cols="50" name="your_message"><?php echo $yourmessage; ?></textarea></p> 
     <p style="line-height: 1.7em;">To help prevent spam, please enter the answer to this question:</p> 
     <p><span><?php echo $number_1; ?> + <?php echo $number_2; ?> = ?</span><input type="text" name="user_answer" /><input type="hidden" name="answer" value="<?php echo $answer; ?>" /></p> 
     <p style="padding-top: 15px"><span>&nbsp;</span><input class="submit" type="submit" name="contact_submitted" value="send" /></p> 
     </div> 
    </form>` 

누가 도와 드릴까요? 오류 : http://i50.tinypic.com/2hfpe7m.jpg.

+0

다시 설치하는 것은 어떻습니까? –

+0

"작동하지 않습니다", "수정하려고했습니다"오류 메시지의 그림에 대한 링크는 매우 불량한 문제 설명입니다 ... –

답변

1

귀하의 페이지에 PHP 명령이 표시된다는 사실은 PHP가 설치되어 있지 않거나 올바르게 구성되어 있지 않음을 나타냅니다. 파일이 실행 중이고 파일 크기가 .php 인 지 확인하십시오.

또한 소스 코드에 <?php 개구부가 누락되었습니다. 질문에 빠져있을 수도 있지만 파일에 있는지 확인하십시오.

+0

그 또한 중괄호 또는 여분의 중괄호가 없음을 나타낼 수 있습니다. – patricksweeney

+0

@patricksweeney 네가 맞아, 내 대답에 그 가능성을 덧붙였다. – Tchoupi

0

PHP 태그가 없습니다.

은 간단히 추가

<?php 

스크립트의 상단.

관련 문제