Here’s my updated code trying to get my form to send me the email. I added the server php requests around the form, though the code doesn’t seem to be reading them. My code is being displayed as text on the site after pushing for the test. I remember once, I called the php in the head away from the form markup but can’t remember that syntax.
Here’s the code I’m trying to use:
<?php
if ($_POST["email"]<>'') {
$ToEmail = 'chaseoutt@gmail.com';
$EmailSubject = 'Site contact form ';
$mailheader = "From: ".$_POST["email"]."\r\n";
$mailheader .= "Reply-To: ".$_POST["email"]."\r\n";
$mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n";
$MESSAGE_BODY = "Name: ".$_POST["name"]."<br>";
$MESSAGE_BODY .= "Email: ".$_POST["email"]."<br>";
$MESSAGE_BODY .= "URL: ".$_POST["url"]."<br>";
$MESSAGE_BODY .= "Comment: ".nl2br($_POST["comment"])."<br>";
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure");
?>
Your message was sent
<?php
} else {
?>
<p style="font-style:italic; font-size:12px; font-weigh: normal; margin-top: -89px; margin-left: 33px;">Contact me written in a different language.</p> <img src="http://www.cameroncashwell.com/imgs/pointing-left.png" style="float: right; margin-right: 140px; margin-top: -89px;">
<div class="form-div">
<form id="fvujq-form1" style="font-size:22px; color:#333;" method="post" action="">
<div class="form-row"><span class="label">Name *</span><input type="text" name="name" /></div>
<div class="form-row"><span class="label">Email *</span><input type="text" name="email" /></div>
<div class="form-row"><span class="label">URL</span><input type="text" name="url" /></div>
<div class="form-row"><span class="label">Comment *</span><textarea name="comment"></textarea></div>
<div class="form-row"><input class="submit" type="submit" value="Submit"></div>
</form>
</div>
<?php
};
?>
Wheres my error?
Email is not sent by JavaScript code in the client; it is sent from the server. When the user hits submit, and all the client side validations have passed, the form data is POST’ed to the server. The form element’s “action” attribute specifies what URL on the server should receive the POST’ed form data; i.e. something like action=”send_email.php” or something like that.
How the email is actually generated, on the server is entirely dependent on the server technology in use, e.g. PHP, or JSP, or whatever.
So two things are missing in your code above: