This is my current code. Why is it not working? It sends mail, but in the $message
section it doesn't pull from $name
, $phone
, or $email
. Also, on the email itself, the $from
doesn't work. The only thing that works correctly is $to
and $subject
.
<?php
if(isset($_POST['submit'])){
$to = "emailgoeshere@example.com";
$from = $_POST['email'];
$name = $_POST['name'];
$subject = "Form submission";
$phone = $_POST['phone'];
$email = $_POST['email'];
$message = $name . " " . $phone . " has the email:" . "
" . $_POST['email'];
$headers = "From: <".$from. ">" ;
mail($to,$subject,$message,$headers);
echo "We have Recieved your Enquiry, We will get back to you soon. We Appreciate Your Patient Thank You.";
}
?>
<div class="right-wrapper">
<div class="contact-form">
<p class="contact-form-info">Leave your contact info below, and we'll contact you shortly:</p>
<form action="https://www.forevrmarketing.com/webdesigndemo/eddy1155/functions/send-mail.php" method="post">
<input type="text" placeholder="Name" class="name" name="name" id="name">
<input type="email" placeholder="Email" class="email" class="email" id="email">
<input type="number" placeholder="Phone" id="phone" class="phone" class="phone" oninput="this.value=this.value.replace(/[^\d]/,'')" maxlength="15">
<input class="submit" type="submit" name="submit" value="Submit">
<div class="loader" disabled><i class="fa fa-spin fa-spinner" aria-hidden="true"></i></div>
<p class="form-details form-era">Call us at <strong style="font-weight: 600">+65 9691 1155</strong> Or <br><span class="wts"><img src="img/icon.png" alt="WhatsApp Icon"></span> <strong style="font-weight: 600">Whatsapp</strong> us</p>
<p class="reponse"></p>
</div>
</div>