Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAshley Carpenter
13,393 Points404 error when sending a form
When I click send on my enquiries form i get a 404 error. My website is www.pagegardenservices.co.uk and its the form on the enquiries page.
The code is
<?php
if ($_SERVER ["REQUEST_METHOD"] == "POST") { $name = $_POST ["name"]; $email = $_POST ["email"]; $message = $_POST ["message"]; $email_body = ""; $email_body = $email_body . "Name: " . $name . "\n"; $email_body = $email_body . "Email: " . $email . "\n"; $email_body = $email_body . "Message: " . $message;
mail('ashley_carpenter@hotmail.com', "New Message", $email_body);
header("location: enquiries.php?status=thanks"); exit;
}
?>
<?php
$pagetitle = 'Enquiries';
$csslink = 'CSS/Enquiries.css';
include 'include/header.php';
?>
<?php if (isset($_GET["status"]) AND $_GET ["status"] == "thanks") { ?> <P>Thanks for sending an email. I'll be in touch</P>
<?php } else { ?>
<div>
<h3 class="grid_12">Send us a Message</h3>
<div class="form">
<form action="enquiries.php" Method="POST" Name="enquiry">
<fieldset>
<div class="yourinfo">
<div class="yourname">
<label for="YourName">Your Name:</label><br>
<input type="text" name="YourName" id="Name"><br><br>
</div>
<div class="youremail">
<label for="YourEmail">Your Email Address:</label><br>
<input type="text" name="YourEmail" id="Email"><br><br>
</div>
</div>
<div class="letusknow">
<label for="enquiry">Let us know:</label><br>
<select name="Option">
</div>
<optgroup label="Existing Customers">
<option>Appointment Times/Dates</option>
<option>Payment</option>
<option>Special Requests</option>
</optgroup>
<optgroup label="New Customers">
<option>One off Project</option>
<option>Continuous Work</option>
<option>Previous Quote</option>
</optgroup>
</select>
<textarea name="enquiry" id="message" rows="10" cols="35"></textarea><br>
<input class="submit" type="submit" value="Send">
</fieldset>
</form>
</div>
</div>
<div>
<div id="somemadtext">
<p>Contact us using our online enquiry form at any time. We'll try and contact you back within 48 hours, although the average response time is usually a lot quicker than this.</p><br><br>
<p>We will be happy to answer any queries whether it is regarding a quote for new work or taking any feedback that you may have.</p>
</div>
</div>
<?php } ?>
<?php
include 'Include/footer.php';
?>
2 Answers
Gábor Balogh
7,503 Pointssorry, the problem is in the form action, you call the enquiries.php but in your website it's capitalized(Enquiries.php). so change the form action or the file name.
Gábor Balogh
7,503 PointsHi! is there the enquiries.php in the server root folder?
Ashley Carpenter
13,393 PointsHi Gabor, I'm not sure i know what you mean, sorry!
Ashley Carpenter
13,393 PointsAshley Carpenter
13,393 PointsThanks very much, I'm not getting the 404 error now. unfortunately I don't think the email is sending though :/