简体   繁体   English

没有变量发送的PHP邮件

[英]PHP Mail sent without the variables

I am setting up a payment page, I am a designer and not a developer. 我正在设置付款页面,我是设计师,而不是开发商。 So I have been having some problems. 所以我一直遇到一些问题。 When the payment is made it goes through several stages and a response is generated. 付款后,它会经历几个阶段,并会生成响应。 In the response.php file that is returned I have an opportunity to inject some code to send an email to the client to inform him that he has received a payment. 在返回的response.php文件中,我有机会注入一些代码以将电子邮件发送给客户,以通知他他已收到付款。

The mail is indeed sent to the client but the variables are missing. 邮件确实已发送到客户端,但是变量丢失。 I receive the text info. 我收到了文字信息。 Anyone out there that can help would be much appreciated. 任何可以提供帮助的人将不胜感激。

$name = $_POST['name'];
$email = $_POST['email'];
$client = $_POST['CUST_NUM'];
$amount = $_POST['AMOUNT'];

$email_from = 'payments@rcehholidaytrust.com';//<== update the email address
$email_subject = "RCEH Website Payment Activity";
$email_body = "You have received a payment from a client $name.\n".
"Account Number:\n $client".
$to = "patrick@patrickmchugh.com";//<== update the email address
$headers = "From: $email_from \r\n";
$headers .= "Reply-To: $email \r\n";
//Send the email!
mail($to,$email_subject,$email_body,$headers);

i changed my answer based on your description 我根据您的描述更改了答案

so if you are not retrieving the $_POST variables then the problem lies not in the PHP code but in your HTML form page*: 因此,如果您不检索$ _POST变量,那么问题就不在于PHP代码,而在于您的HTML表单页面*:

$name = $_POST['name'];       
$email = $_POST['email'];
$client = $_POST['CUST_NUM'];
$amount = $_POST['AMOUNT'];

can you check if your form fields contain the same names as the list above inside the $_POST. 您可以检查表单字段是否包含与$ _POST内上面列表相同的名称。 for example: 例如:

$_POST['name'] will get it's values from a textbox/field that has a name='name': $ _POST ['name']将从具有name ='name'的文本框/字段中获取其值:

<input type="textbox" name="name">

$_POST['CUST_NUM'] will get it's values from a textbox/field that has a name='CUST_NUM': $ _POST ['CUST_NUM']将从名称为'CUST_NUM'的文本框/字段中获取其值:

<input type="textbox" name="CUST_NUM">

now if you are still having problems getting those variables: 现在,如果您仍然无法获取这些变量:

it might be because you are not passing it in the right url 可能是因为您没有在正确的网址中传递它

if your php code your_php_code.php nd your html is found in the same directory: 如果您的php代码your_php_code.php和您的html位于同一目录中:

<form method="POST" action="your_php_code.php">
... your other codes here ...
</form>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM