Hey everyone,
I’m using a free template for a site I have set up. This template didn’t come with any php or any code at all to make the contact form work. I’ve been trying to make it work with a VERY BASIC php submit file I have from an old site.
However, it’s been years since I’ve worked with php and I’m sure many things have changed as well as the fact that I’m working from the ground up with this html because it didn’t come with a matching php form of it’s own.
Here’s the html for the contact section:
[code=html]<article id=”main”>
<div id=”contact”></div>
<header class=”special container”>
<span class=”icon fa-comments-o”></span>
<h2>Send me a Message</h2>
<p>Use the form below if you have any questions, or you just want to get in touch!</p>
</header>
<!– One –>
<section class=”wrapper style4 special container small”>
<!– Content –>
<div class=”content”>
<form>
<div class=”row half no-collapse-1″>
<div class=”6u”>
<input type=”text” name=”name” placeholder=”Name” />
</div>
<div class=”6u”>
<input type=”text” name=”email” placeholder=”Email” />
</div>
</div>
<div class=”row half”>
<div class=”12u”>
<input type=”text” name=”subject” placeholder=”Subject” />
</div>
</div>
<div class=”row half”>
<div class=”12u”>
<textarea name=”message” placeholder=”Message” rows=”7″></textarea>
</div>
</div>
<div class=”row”>
<div class=”12u”>
<ul class=”buttons”>
<li><a href=”/send.php” class=”button special”>Send Message</a></li>
</ul>
</div>
</div>
</form>
</div>
</section>
</article>
And here’s the php I’m using:
[code=php]<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
</head>
<body>
<?php
$email_to = “[email protected]”;
$name = $_POST[“name”];
$email = $_POST[“email”];
$subject = $_POST[“subject”];
$message = $_POST[“message”];
$text = “Name: $name<br>
Email: $email<br>
Subject: $subject<br>
Message: $message”;
$headers = “MIME-Version: 1.0” . “rn”;
$headers .= “Content-type:text/html; charset=utf-8” . “rn”;
$headers .= “From: <$email>” . “rn”;
mail($email_to, “Message from Yoga Website”, $text, $headers);
?>
</body>
</html>
The form will submit, but the email I receive doesn’t contain any of the inputted info, just the labels from the php form. Also, I would like the form to redirect to the homepage after submission.
I would really appreciate any help, it’s been so long since I worked on this stuff that I’ve totally forgotten everything!!
Thanks,
-Jess