Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP Build a Simple PHP Application Adding a Contact Form Working with Post Variables

Working with Post Variables

No idea why this form isn't working. What happens is that when i click on the submit button, it doesn't go anywhere and stays on the same page when I want it to go to the 'contact-process.php' that i have set to in the action attribute.

<form class="contact" method="post" action="contact-process.php">
    <input type="text" name="name" value="Name" />
    <input type="text" name="email" value="E-mail" />
    <textarea name="message">Message</textarea>
    <input type="submit" value="" />
</form>

I have a feeling that there needs to be more explanation and I found it easier to just hit record: http://www.youtube.com/watch?v=J9CRiPz0fMU&feature=youtu.be

Anyone know what the deal is? Let me know if you guys find something. Thanks!

4 Answers

Sorry if I hit [ask], you guys were listed on the suggested users that are most likely to answer. Thought you guys would be interested. Thanks!

Honestly, that is very odd. Your HTML should be processed how you have it scripted and when you moved it in your video to the stand-alone page it worked. The only thing I can think of is if you have some overlay with your styling that is preventing you from clicking. Your form looked a little different when you brought it to its own page. To troubleshoot this, just bring your submit to a line on its own (change your styling around) and see if you can submit it.

delete

It seems like nothing is wrong with the layout of the form... but when it's included into a footer.php called in to the page using the php method include(), it breaks the functionality of the submit button. Is this possible that the include('footer.php') with a form field attached inside would lose its functionality when called into another page?

It shouldn't. The only issue that you might run into is directory issues if your form processing file isn't being hit with the new location of the form. That truly is a peculiar issue. Have you tried posting the page into W3C Validator? It might point you in a specific direction with your DOM.