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 trial

PHP

marsha grasett
marsha grasett
9,995 Points

testing contact form on local server?

Can this be done?

I want to see if the success message "Message was sent successfully!"

Site is html- with js and php

I have MAMP on a mac. But, thought it was just for php.

(Yah, still working on my contact form :worried:)

11 Answers

J.T. Gralka
J.T. Gralka
20,126 Points

Marsha,

Which badge are you working on? Andrew's jQuery course or Randy's PHP course? I'd be more than happy to help answer any questions you have about either -- and yes, you should be able to simulate both projects using MAMP or XAMPP with Mac OS X.

Best,

J.T.

marsha grasett
marsha grasett
9,995 Points

Hi J.T. Gralka

I am working on my own site and am stuck on my contact form (after watching Andrew's and Randy's tutorials numerous times)

And I got MAMP working fine, now, and testing a simple form.

My BIG question-- After all areas are validated and form submitted I would like a "Your message was was sent" to appear just below the form. Not in a new window. Is this possible/

I am going around in circles and brain dead lol

J.T. Gralka
J.T. Gralka
20,126 Points

Yep! That's certainly possible. If you haven't already, I would suggest you watch Randy's Integrated Validation Errors course videos. It builds upon the contact form validation content he teaches in his introductory course. Specifically, this intermediate course provides an in depth survey of how to get error and validation messages to display on the same page as the form. I think this is a very well done course, and I think you'll find the validation stuff both intriguing and extremely functional!

If you still find yourself struggling, let me know; I'd be happy to help you through it!

J.T.

marsha grasett
marsha grasett
9,995 Points

How did I miss this? Looks perfect. Thanks!

My site is in HTML. Will this work for me?

J.T. Gralka
J.T. Gralka
20,126 Points

You might change the file extensions to .php, but as long as the HTML is semantic, you should be just fine!

marsha grasett
marsha grasett
9,995 Points

I have watched the videos.

How can I put php into my HTML files. I am stuck. Here is an example:

<form class="email" action="contact.php" method="post">

        <p><label for="name">Name&#42;</label></p>
            <p> 
            <input type="text" name="name" id="name" class="required" value="<?php if (isset($name)) { echo $name; } ?>">
            </p>
marsha grasett
marsha grasett
9,995 Points

Never mind ...

I just found out I have to change the file extensions to .php

:-)

J.T. Gralka
J.T. Gralka
20,126 Points

Yeah. Apache makes you do that... Also, your form looks pretty good; the only thing I might change is that I would add the htmlspecialchars() function for security's sake.

<input type="text" name="name" id="name" class="required" value="
    <?php
        if (isset($name)) {
            echo htmlspecialchars($name);
        }
    ?>">

I'm not sure how far you've made it through the course, but Randy does cover that at some point. Let me know if you're still having trouble with anything. :)

J.T.

J.T. Gralka
J.T. Gralka
20,126 Points

You're quite welcome! :-)

marsha grasett
marsha grasett
9,995 Points

yay!!! Contact Form (seems to be working)

But another BIG question.

My site is a long one pager. Contact Form appears at the bottom just before small footer.

I have changed the -- action="contact.php" --- to---

<form method="post" action="index.php" id="contactform">

But now when I submit the form the page goes up to the top of the site.

How can I get it to remain at the bottom where the contact form is? I have tried it with the nav <a href> " #contact" ---like so---

action="index#contact.php"

Any help, pleaze :/