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 = "garybrowntown@gmail.com";
    $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>
4

3 に答える 3

1

おそらく、戻りメッセージをphp TAGSでラップすると、正しく機能します。見てみましょう:

<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>
于 2012-10-23T12:25:45.167 に答える
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>'; 

このチュートリアルを進めます

于 2012-10-23T12:24:03.967 に答える
-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>";
于 2012-10-23T12:23:45.183 に答える