I'm sure I'm just missing something really simple, because I'm burned out from coding. Can someone please spot what the problem is? When submitted the form emails the info, but none of the variables (like firstname, lastname, etc) are being included in the email.
All I get is this:
From:
Phone: --
Call Back:
Best time to call:
Message:
If you can find what the problem is - I will be very thankful.
Here is the form HTML:
<form action="mail.php" method="POST" id="main_form" onSubmit="this.reset();">
<p>First Name</p> <input type="text" name="firstname" size="93" style="width:475px; float:left;"><br />
<p>Last Name</p> <input type="text" name="lastname" size="93" style="width:475px; float:left;"><br />
<p>Email</p> <input type="text" name="email" size="93" style="width:475px; float:left;"><br />
<p>Confirm E-mail</p> <input type="text" name="confirmemail" size="93" style="width:475px; float:left;"><br />
<p>Contact Number<br />
<input type = "text" id = "Ph1" name="Ph1" size =" 3" maxlength = "3" onkeyup = "validate(this,2)">-
<input type = "text" id = "Ph2" name="Ph2" size =" 3" maxlength = "3" onkeyup = "validate(this,3)">-
<input type = "text" id = "Ph3" name="Ph3" size =" 4" maxlength = "4" onkeyup = "validate(this,3)">
</p>
<script type = "text/javascript">
function validate(which,next) {
var val = which.value;
val = val.replace(/[^0-9]/g,""); // strip non-digits
which.value = val;
next = "Ph" + next;
if (val.length == 3) { // field completed
document.getElementById(next).focus()
}
}
</script>
<p>Request Phone Call:<br />
<span style="font-family:'Open Sans', serif; font-size:14px;">Yes:</span><input type="radio" value="Yes" name="call">
<span style="font-family:'Open Sans', serif; font-size:14px;">No:</span><input type="radio" value="No" name="call"><br />
</p>
<p>Best time to contact:<br />
<span style="font-family:'Open Sans', serif; font-size:14px;">Morning:<input type="radio" value="Morning" name="calltime">
<span style="font-family:'Open Sans', serif; font-size:14px;">Afternoon:<input type="radio" value="Afternoon" name="calltime">
<span style="font-family:'Open Sans', serif; font-size:14px;">Evening:<input type="radio" value="Evening" name="calltime"><br />
</p>
<p>Message</p><textarea name="message" rows="6" cols="67"></textarea><br />
<input class = "_submit"type="submit" value="SUBMIT" style="width: 128px;
height: 36px;
font-family: 'Pathway Gothic One', serif;
font-size: 28px;
border-radius: 0px;
border-width: 0px;
color: #FFF;
background-color: #FFCA04; float:left; margin-top: 10px;">
</form>
Here is the mail.php
<?php
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];
$confirmemail = $_POST['confirmemail'];
$phone1 = $_POST['Ph1'];
$phone2 = $_POST['Ph2'];
$phone3 = $_POST['Ph3'];
$call = $_POST['call'];
$calltime = $_POST['calltime'];
$message = $_POST['message'];
$formcontent=" From: $firstname $lastname \n Phone: $phone1-$phone2-$phone3 \n Call Back: $call \n Best time to call: $calltime \n Message: $message";
$recipient = "MyEmail@domain.com";
$subject = "YOU HAVE A MESSAGE FROM WEBSITE CONTACT PAGE";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!" . " -" . "<a href='form.html' style='text-decoration:none;color:#ff0099;'> Return Home</a>";
?>