I'm needing to be able to fill in a form on a password protected webpage that then sends the information to the end user but it also needs to send a copy to the generic sales email address.
I've been at this for a while and have managed to get it to send emails but they only end up sending to the noreply address.
index.php
<form method="post" name="process.php" action="process.php">
<p>Customer Name:</p><br><input type="text" name="name">
<p>Customer Email Address:</p><br><input type="text" name="email">
<p>Customer Order Number:</p><br><input type="text" name="order">
<p>Customer Order Date:</p><br><input type="text" name="date">
<p>Total Paid:</p><br><input type="text" name="cost">
<p>Tracking Number:</p><br><input type="text" name="tracking">
<br>
process.php
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$order = $_POST['order'];
$date = $_POST['date'];
$cost = $_POST['cost'];
$tracking = $_POST['tracking'];
?>
<?php
$email_from = "noreply@example.com";
$email_subject = "Your order details";
$email_body = "Hello,\n $name.\n".
"Your order number is:\n $order".
"Your order was placed on:\n $date".
"Your total cost is:\n $cost".
"Your tracking number is:\n $tracking".
"You can track your order on our website.\n".
"Thanks,\n examplecompany \n".
$to = $email.
$bcc = "sales@example.com".
$headers = "From: noreply@example.com \r\n";
$headers .= "Reply-To: constact@example.com \r\n";
mail($to,$email_subject,$email_body);
?>
<p>Sending Email…</p>
<meta http-equiv="refresh" content="10000;URL='https://staff.example.com/fulfilment/confirmorder/#useremail'"/>
What should happen is that the email should send to the user and a copy (using BCC) to the sales@ email address. Currently the email no longer sends and the inputs from the form aren't included in the order.
The code above has the form (which is on a separate page in the same directory) and the process.php document.
Any help would be appreciated to get the email to send to both the user and the sales account and also include the actual form inputs.
UPDATE: And with a HTML email body
With a HTML email body it's easier for me to include links and the company logo.
$email_body = '
<body>
<div>
Hello,<?php $name ?><br><br>
Your order number is: <strong><?php $order ?></strong><br>
Your order was placed on: <strong><?php $date ?></strong><br>
Your total cost is: <strong>£<?php $cost ?></strong><br>
Your tracking number is: <strong><?php $tracking ?></strong><br>
You can track your order on our website <a href="https://example.com/track">here</a>.<br><br>
Thanks,<br>examplecompany.<br>
<a href="https://example.com"><img src="https://example/assets/images/logo.png" alt="examplecompany logo" width="200px"></a>
</div>';
Everything works in a text email apart from displaying the PHP $name
tags etc.