Forums Get help. Give help.
Simple Contact form
-
Hi All,
I downloaded Chris's simple contact form, and, since I know pretty much nothing about PHP, I was hoping to get some help..
Below is my markup:<form id="contact-form" action = "contactengine.php" method = "post">
<fieldset id="texfields" class="grid_4 alpha">
<ul>
<li>
<label for="name">Name</label><br>
<input id="name" name="name" type="text" placeholder="First and last name" required>
</li>
<li>
<label for="email">Email</label><br>
<input id="email" name="email" type="email" placeholder="example@domain.com" required>
</li>
<li>
<label for="phone">Phone</label><br>
<input id="phone" name="phone" type="tel" placeholder="Eg.000.000.0000" required>
</li>
</ul>
</fieldset>
<fieldset id="comments" class="grid_4 omega">
<label for="comments">Comments</label><br>
<textarea id="comments" name="comments" placeholder="Type your message here"required></textarea><br>
<button type="submit" class="grid_1">Send</button>
</fieldset>
</form>
And this is the PHP that I modified (I was hoping that's what I had to do) to match my markup:<?php
$EmailFrom = "chriscoyier@gmail.com";
$EmailTo = "info@dreamgem.net";
$Subject = "Nice & Simple Contact Form by CSS-Tricks";
$Name = Trim(stripslashes($_POST['name']));
$Email = Trim(stripslashes($_POST['email']));
$Phone = Trim(stripslashes($_POST['phone']));
$Comments = Trim(stripslashes($_POST['comments']));
// validation
$validationOK=true;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
exit;
}
// prepare email body text
$Body = "";
$Body .= "name: ";
$Body .= $name;
$Body .= "\n";
$Body .= "email: ";
$Body .= $email;
$Body .= "\n";
$Body .= "phone: ";
$Body .= $phone;
$Body .= "\n";
$Body .= "comments: ";
$Body .= $comments;
$Body .= "\n";
// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>
My issues are:
1. I receive the email, but the content is empty
2. How do I modify the From field so that it would show actual email it came from instead of static email I set..
3. I would like to get rid of the re-direct page as I'm using this form on the footer of a website..
Thanks a bunch in advance and sorry for very basic question!
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Categories
- All Discussions15,493
- CSS Combat7,193
- Other Discussions3,820
- JavaScript Jungle2,455
- PHP Problems2,025
Tips
Just some helpful hints to get the most out of the forums.
