1

私は最近フォームを作成し(以下を参照)、フォームから送信ボタンを押したときに送信されるメールを設定するphpスクリプトを書くことができました。問題は、$message 変数の php スクリプトでは、電子メールで送信されるのは文字列だけであり、$name、$customer_number などの変数ではないことです。

誰か親切にエラーを指摘してくれませんか?

フォーム:

<form name="bookingForm" method="post" action="send_dates.php">
<table border="0" cellspacing="1" cellpadding="2">

<tr>
<td>Booking From</td>
<td>:</td>
<td><input name="fromDate" id="fromDate" size="20"></td>

<td>To</td>
<td>:</td>
<td><input name="toDate" id="toDate" size="20"></td>
</tr>

<tr>
    <td>Name</td>
    <td>:</td>
    <td><input name="name" id="name" size="30"></td>
</tr>

<tr>
    <td width="20px">Telephone</td>
    <td>:</td>
    <td><input name="customer_telephone" id="customer_telephone" size="30"></td>
</tr>

<tr>
    <td width="20px">Email</td>
    <td>:</td>
    <td><input name="customer_email" id="customer_email" size="30"></td>
</tr>

<tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><input type="submit" name="submit" value="Submit" onClick="document.getElementById('ResetForm').click();">
    <input type="reset" name="ResetForm" id="ResetForm" value="Reset"></td>
</tr>
</table>
    </form>

PHP スクリプト send_data:

<?php
$name = $_POST["name"];
$fromDate = $_POST["fromDate"];
$toDate = $_POST["toDate"];
$email = $_POST["customer_email"];
$telephone = $_POST["customer_telephone"];

// Mail of recievers
$to = "ucjulian@gmail.com";

// Contact subject
$subject ="Reservation Enquiry from $name";

// Details
$message="
From: $name
Email: $customer_email
Telephone: $customer_telephone
--------------------------------------------------------------
Reservation date from: $fromDate to: $toDate ";

// Mail of sender
$mail_from="$customer_email";

$rev = mail($to,$subject,$message);

if($rev) {
    echo 'booking request has been sent!';
}
else {
    echo 'something has gone wrong. Please try again!';
} ?>
4

3 に答える 3

6

$email変数をおよびとして定義していますが、それぞれおよび$telephoneとして使用しています。$customer_email$customer_telephone

いずれかの領域で名前の使用法を更新すると、設定する必要があります。

于 2012-07-26T16:54:18.800 に答える
1

変数名が間違っています。交換

From: $name
Email: $customer_email
Telephone: $customer_telephone

From: $name
Email: $email
Telephone: $telephone
于 2012-07-26T16:54:50.727 に答える
0

register_globals をオフにしている場合 [このようになる可能性が高い] $message で $customer_telephone の代わりに $telephone を使用することをお勧めします

于 2012-07-26T16:55:22.137 に答える