Very Basic PHP Contact Form Issues
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:
And here's the php I'm using:
<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>
<!-- One -->
<section class="wrapper style4 special container small">
<!-- Content -->
<div class="row half no-collapse-1">
<input type="text" name="name" placeholder="Name" />
<input type="text" name="email" placeholder="Email" />
<div class="row half">
<input type="text" name="subject" placeholder="Subject" />
<div class="row half">
<textarea name="message" placeholder="Message" rows="7"></textarea>
<li><a href="/send.php" class="button special">Send Message</a></li>
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.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
$email_to = "email@example.com";
$name = $_POST["name"];
$email = $_POST["email"];
$subject = $_POST["subject"];
$message = $_POST["message"];
$text = "Name: $name<br>
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html; charset=utf-8" . "\r\n";
$headers .= "From: <$email>" . "\r\n";
mail($email_to, "Message from Yoga Website", $text, $headers);
I would really appreciate any help, it's been so long since I worked on this stuff that I've totally forgotten everything!!
Are your html skills that rusty?
Your form tag has no attributes, such as Method= or action= which will trigger the correct script to be run upon submission as well as the correct Array to use to retrieve data. By default the method will be GET,meaning that you need to either change it to POST or alter all of your php code to reference the $_GET array
Your form tag should be like this.
<form action="phppagehere.php" method="POST">
This is how your php code gets all of its information to send to you. I hope this helps, if not let me know!
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)