I've got a simple PHP email form. This is going to be used for multiple people, so in order to make it easier for people, I have a hidden input field in my html form that is basically the "mailTo" email address.
How do I get the email to send the email to the address provided in the hidden input field?
Here's my HTML:
<div id="formholder">
<form method="post" action="http://www.artofliz.com/hosting/php/process.php">
<!-- THE CLIENT'S EMAIL TO ADDRESS GOES HERE!!! -->
<input name="to" type="hidden" value="lroberts@platinumstrategies.com" />
<label for="name">Name</label>
<input name="name" placeholder="Full Name" type="text" />
<label for="email">Email</label>
<input name="email" placeholder="youremail@example.com" type="email" />
<label for="phone">Phone</label>
<input name="phone" placeholder="XXX-XXX-XXXX" type="tel" />
<input id="submit" name="submit" type="submit" value="Submit" />
</form>
</div>
Here is my PHP handler:
<?php
$to = $_POST['to'];
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$from = 'From: noreply@platinumstrategies.com';
// $to = 'lroberts@platinumstrategies.com';
$subject = 'Free Guide Download';
$body = "From: $name
Email: $email
Phone: $phone";
if ($_POST['submit']) {
/* Anything that goes in here is only performed if the form is submitted */
if (mail ($to, $subject, $body, $from)) {
echo '<p>Your message has been sent!</p>';
} else {
echo '<p>Something went wrong, go back and try again!</p>';
}
}
?>
http://pastebin.com/cqZP949r - Additionally, I should note that the 'to'
that's commented out works fine. It's what I'm trying to do currently that's broken.
Thank you very much for your help.