0

冗談のタイトルを許してください、しかし私は私の連絡フォームが正しく機能するようにするために最後の1時間努力してきました。メールは問題なく送信されますが、関連するすべてのデータ(名前、メールなど)が除外されます。

PHPの連絡先フォームのチュートリアルを変更しましたが、どこが間違っているのかわかりません。

HTML:

<form name="form1" method="post" action="send_contact.php">
<fieldset>
    <h3>Name</h3>
    <input name="name" type="text" id="name">

    <h3>Email (required)</h3>
    <input name="email" type="text" id="email">

    <h3>Phone (required)</h3>
    <input name="telephone" type="text" id="telephone">

    <h3>Desired appointment time/date</h3>
    <input name="time" type="text" id="time">

    <input type="submit" name="Submit" value="Submit">

</fieldset>
</form>

PHP:

<?php
// customer name
$customer_name = "$name";
// customer email
$mail_from = "$email";
// customer telephone
$customer_telephone = "$telephone";
// desired appointment time
$appointment_time = "$time";

// subject
$subject = "Appointment for $customer_name";
// message
$message = "$customer_name would like to book an appointment for $appointment_time";
// header
$header = "from: $customer_name <$mail_from>";
// recipient
$to = 'my@emailaddress.com'; 

$send_contact = mail($to,$subject,$message,$header);

if($send_contact){
    echo "We've recived your contact information";
}
else {
    echo "ERROR";
}
?>
4

3 に答える 3

2

引用符は必要ありません。

$customer_name = "$name";
$customer_name = $name;

データを取得するには、実際にpostを使用する必要があります。

$customer_name = $_POST['name'];
于 2011-09-13T02:46:28.600 に答える
1

変数のスーパーグローバル$_POSTを調べる必要があります。例えば

$customer_name = $_POST['name'];
于 2011-09-13T02:47:24.903 に答える
1

あなたがデータを投稿する場合、あなたは投稿からそれを取得する必要があります:私もそれをトリミングします

$customer_name = trim( $_POST['name'] );
于 2011-09-13T02:48:20.557 に答える