2012-10-23 26 views
2

我遇到了類似的問題,但我一直無法解決我的聯繫表單問題。這是我通過我的電子郵件中的聯繫表單收到的。聯繫表格不返回任何內容?

<p>$usersname has contacted you from your site.</p> 
<h3>Their Message is as follows:</h3> 
<p>$usersmessage</p> 
<h5>Contact details</h5> 
<p>Phone Number: $usersphonenumber</p> 
<p>Email Address: $usersemail</p> 
<?php 
    if(isset($_REQUEST['contactformid']) && $_REQUEST['contactformid'] == 1){ 
    $youremail = "[email protected]"; 
    $usersname = $_POST["usersname"]; 
    $usersemail = $_POST["usersemail"]; 
    $usersphonenumber = $_POST["usersphonenumber"]; 
    $usersmessage = $_POST["usersmessage"]; 
    $subject = 'Message From Your Contact Form'; 
    $message = '<p>$usersname has contacted you from your site.</p> 
<h3>Their Message is as follows:</h3> 
<p>$usersmessage</p> 
<h5>Contact details</h5> 
<p>Phone Number: $usersphonenumber</p> 
<p>Email Address: $usersemail</p>'; 
$headers = 'From:' . $usersemail . "\r\n"; 
    mail($youremail, $subject, $message, $headers); 

    echo '<p>Thank you for your email, a member of our staff will contact you soon regarding your email!</p>'; 

} else { 
    echo '<p>Form could not be sent, please try again!</p>'; 
} 

?> 

    <div class="boxes-full"> 

      <div class="contacttitle"> 

       <h2>Contact Mogul</h2> 

      </div> 

      <div class="boxes-padding fullpadding"> 

      <div id="contactwarning"></div> 
      <div id="contactajax"></div> 

      <form action="javascript:parseResponse();" method="post" name="ajaxcontactform" id="ajaxcontactform"> 

       <div class="contacttextarea"> 
        <input name="contactformid" id="contactformid" type="hidden" value="1" /> 

        <fieldset> 
         <textarea name="comment" id="comment" cols="5" rows="5" class="contacttextarea"onfocus="if (this.value == 'Please Leave A Message') {this.value = '';}">Please Leave A Message</textarea> 
        </fieldset> 

       </div> 

       <div class="contacttextboxes"> 

        <fieldset> 
         <input id="name" name="name" type="text" class="contacttextform" onfocus="if (this.value == 'Please Insert Your Name') {this.value = '';}"value="Please Insert Your Name"> 
        </fieldset> 

        <fieldset> 
         <input id="phone" name="phone" type="text" class="contacttextform" onfocus="if (this.value == 'Please Insert Your Phone Number') {this.value = '';}"value="Please Insert Your Phone Number"> 
        </fieldset> 

        <fieldset> 
         <input id="email" name="email" type="text" class="contacttextform" onfocus="if (this.value == 'Please Insert Your Email') {this.value = '';}"value="Please Insert Your Email"> 
        </fieldset> 

        <fieldset> 
         <input name="send" type="submit" class="contactformbutton" value="Send"> 
        </fieldset> 

       </div> 

      </form> 

      </div> 

      <span class="box-arrow"></span> 

     </div> 

回答

-1

你,如果你希望在你的字符串中的變量用雙引號,所以更換你的下面的代碼:

$message = '<p>$usersname has contacted you from your site.</p> 
       <h3>Their Message is as follows:</h3> 
       <p>$usersmessage</p> 
       <h5>Contact details</h5> 
       <p>Phone Number: $usersphonenumber</p> 
       <p>Email Address: $usersemail</p>'; 

這一個:

$message = "<p>$usersname has contacted you from your site.</p> 
       <h3>Their Message is as follows:</h3> 
       <p>$usersmessage</p> 
       <h5>Contact details</h5> 
       <p>Phone Number: $usersphonenumber</p> 
       <p>Email Address: $usersemail</p>"; 
+0

爲什麼downvoted?謹慎解釋? – Nelson

0

那是因爲你正在使用單引號和變量不被評估,試試這個代碼它會工作。

$message = '<p>'.$usersname.' has contacted you from your site.</p> 
        <h3>Their Message is as follows:</h3> 
        <p>'.$usersmessage.'</p> 
        <h5>Contact details</h5> 
        <p>Phone Number: '.$usersphonenumber.'</p> 
        <p>Email Address: '.$usersemail.'</p>'; 

,並通過這個tutorial

1

或許,如果你在PHP標籤包裹返回消息它將正常工作。 請看:

<p>$usersname has contacted you from your site.</p> 
           <h3>Their Message is as follows:</h3> 
           <p>$usersmessage</p> 
           <h5>Contact details</h5> 
           <p>Phone Number: $usersphonenumber</p> 
           <p>Email Address: $usersemail</p> 

使用這樣的:

<p><?php echo $usersname; ?> has contacted you from your site.</p> 
           <h3>Their Message is as follows:</h3> 
           <p><?php echo $usersmessage; ?></p> 
           <h5>Contact details</h5> 
           <p>Phone Number: <?php echo $usersphonenumber; ?></p> 
           <p>Email Address: <?php echo $usersemail; ?></p> 
相關問題