Reputation: 11
<form id="contact-form" class="contact-form" action="contact.php">
<p class="contact-name">
<input id="contactName" type="text" placeholder="Full Name" name="contactName" />
</p>
<p class="contact-email">
<input id="contactEmail" type="text" placeholder="Email Address" name="contactEmail" />
</p>
<p class="contact-message">
<textarea id="contactMessage" placeholder="Your Message" name="contactMessage" rows="15" cols="40"></textarea>
</p>
<p class="contact-submit">
<button type="submit" class="btn btn-inverse" id="contactSubmit">Submit</button>
</p>
</form>
That is the form html, below is the php
<?php
$name = $_POST['contactName'];
$email = $_POST['contactEmail'];
$message = $_POST['contactMessage'];
$formcontent=" From: $name \n Email: $email \n Message: $message";
$recipient = "[email protected],";
$subject = "Contact Form";
$mailheader = "From: $email \r\n";
$success=mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
header('Location: http://www.website.com');
?>
I get the email but the user info they input doesn't show up in the email. I have used the same code before and I thought it worked but now this isn't so I am very confused. Thanks
Upvotes: 0
Views: 68
Reputation: 622
Try with method = "POST"
<form id="contact-form" class="contact-form" action="contact.php" method="POST">
The default value is "GET" so your vars doesn't exists
Upvotes: 1
Reputation: 12196
The default for form
element is the method
GET
and not POST
. Thus, If you leave it empty it will act as if you used method="get"
.
Add method="post"
to your form
element.
<form id="contact-form" class="contact-form" action="contact.php" method="post">
Upvotes: 4