Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP-变量问题_Php_Variables - Fatal编程技术网

PHP-变量问题

PHP-变量问题,php,variables,Php,Variables,我最近构建了一个表单(见下文),并编写了一个php脚本,在该脚本中,我设置了当我按下表单中的提交按钮时要发送的邮件。问题在于,在$message变量中的php脚本中,通过电子邮件发送的唯一内容是字符串,而不是$name、$customer\u number等变量 谁能帮我指出错误吗 表格: <form name="bookingForm" method="post" action="send_dates.php"> <table border="0" cellspacing="

我最近构建了一个表单(见下文),并编写了一个php脚本,在该脚本中,我设置了当我按下表单中的提交按钮时要发送的邮件。问题在于,在$message变量中的php脚本中,通过电子邮件发送的唯一内容是字符串,而不是$name、$customer\u 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脚本发送\u数据:

<?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!';
} ?>

您将变量定义为
$email
$telephone
,但将它们分别用作
$customer\u email
$customer\u telephone


更新任一区域中的名称用法,您应该进行设置。

您将变量定义为
$email
$telephone
,但将它们分别用作
$customer\u email
$customer\u telephone


更新任一区域中的名称用法,您应该进行设置。

您的变量名称错误。替换

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


您有一个错误的变量名。替换

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


如果您已关闭[可能是这种方式],您最好在$message中使用$telephone而不是$customer\u telephone

如果您已关闭[可能是这种方式]您最好在$message中使用$telephone而不是$customer\u telephone

在$\u POST上进行var\u转储的结果是什么?在$\u POST上进行var\u转储的结果是什么?多么愚蠢的错误,我一直在输入框中输入名称而不是变量:-这是一个愚蠢的错误,我一直在输入框中输入名称,而不是变量:-S