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 Redirection Page Problem

hi i am a newbie can someone tell me what is wrong with the code, i cannot redirect it to "thank you page" after clicking the submit button. it direct me to a page telling

Not Found

The requested URL /method= was not found on this server.

here's the code:

      <title>form test</title>
  <form action=" method=" post " action=" form2.php " >
    <p>Your name: <input type="text" name="name" /></p>
    <p>Your age: <input type="text" name="age" /></p>
    <p><input type="submit" name="submit" value="send"/></p>
if (isset ($_POST['submit']))
    header("location: http://localhost/thanks.php");

4 Answers

Matt Campbell
Matt Campbell
9,767 Points

@de luna

You need to take out the url and use the filename so it should be:


And I'm not sure what you've got going on on the form line. It should read

<form action="form2.php" method="post"></form>

I'd change the age input field to an integer as that is what it is.

Take the submit input out of <p> tags as it is a button and doesn't need to be.

I'm guessing the php script has a closing tag but is off the page.

I think that's all right, I'm pretty new to this myself but give it a whirl and see what happens. :)

Randy Hoyt
Randy Hoyt
Treehouse Guest Teacher

I would recommend looking at my videos here on Treehouse about adding a contact form to a PHP site.

I cover everything you are trying to accomplish here.

Matt Campbell
Matt Campbell
9,767 Points

Definitely watch Randy Hoyt 's videos as what I've written is what I learnt from them. It was only last Monday I think I started the PHP lesson so there may be errors in what I wrote.

Randy's videos are awesome.

thank You tree house(Randy, Matthew)...:-) got it will be able to move on now...