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 trialKaitlyn Threndyle
18,204 PointsUpon filling out form and clicking "submit" it opens orginal process.php in the browser
I've downloaded MAMP and set it to root from my personal website folder. I've also copied the php in the video to work with my form. But when i fill out the form and click submit it just opens process.php file. It doesn't even have any of the new info from what had been filled out. I have made the form in my index.html file and used action="process.php" method="post". Does anyone know what could be wrong?
<?php
$name = $_POST["name"];
$email = $_POST["email"];
$company = $_POST["company"];
$message = $_POST["message"];
echo "<pre>";
$email_body = "";
$email_body .= "Name " . $name . "\n";
$email_body .= "Email " . $email . "\n";
$email_body .= "Company " . $company . "\n";
$email_body .= "Message " . $message . "\n";
echo $email_body;
echo "</pre>";
?>
<form class="contact_form" action="process.php" method="post">
<ul>
<li><label for="form-name" class="sr-only">Name:</label> <input type="text" name="name" id="form-name" placeholder="Name"></li>
<li><label for="form-email" class="sr-only">Email:</label> <input type="email" name="email" id="form-email" placeholder="Email"></li>
<li><label for="form-company" class="sr-only">Company:</label> <input type="text" name="company" id="form-company" placeholder="Company"></li>
<li><label for="form-message" class="sr-only">Message:</label><br>
<textarea name="message" rows="4" cols="50" id="form-message" placeholder="Leave me a message!"></textarea>
</li>
</ul>
<input class="btn_ btn-submit" type="submit" value="Send">
</form>
Kaitlyn Threndyle
18,204 PointsHi Ben, thanks for your response. After submission it displays exactly the same as the code above. There are no errors just exact same code.
Benjamin Larson
34,055 PointsIf it's displaying the code itself, then the most likely culprit is that they Apache webserver isn't running. I've only used XAMPP on a Windows environment so I'm not really familiar with the interface for MAMP, but when you ran it, did you click something to start all the servers as well?
Kaitlyn Threndyle
18,204 PointsI also also feel the problem is probably something with the server. I did press "start servers" but maybe i havent directed it properly. There were some errors after i installed MAMP which caused me to have to download Visual C++ something or other, but i seemed to be running after I installed those missing files. I'll try messing around with it a bit more.....thanks though.
Benjamin Larson
34,055 PointsAre you accessing the file directly, or on the localhost? Does the URL display your drive letter and directories or is it http://localhost/index.html?
1 Answer
Maximillian Fox
Courses Plus Student 9,236 PointsIf you have the server running, make sure you are not opening the file directly from your filesystem.
In Xampp it would be located like this - not sure if htdocs exists in MAMP, but you will need to put all your site files into the equivalent of htdocs - check their documentation for help on this - but what you don't want to do is open this in your address bar: c\myaccount\somepath\htdocs\mywebsitefolder\index.html
You will want to instead use the web address variant like this: http://localhost/mywebsitefolder/index.html or http://127.0.0.1/mywebsitefolder/index.html
Does the page run if you open it on localhost? Also if this doesn't work can you let us know the path to your index.html file and also the path to your MAMP installation, and I will see if I can help :)
Benjamin Larson
34,055 PointsBenjamin Larson
34,055 PointsHi Kaitlyn,
Does anything display on the process.php page in the browser when you submit the form? Is it blank, or does it display any kind of errors/warnings/notices? Does it display the code itself that you have above?