简体   繁体   中英

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.

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*:

$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. for example:

$_POST['name'] will get it's values from a textbox/field that has a 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':

<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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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