Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Redirect to thank you page on form submit WordPress

  • SOLVED

I have 'inherited' a form for a wordpress website from an old website.

Once the form has been completed and submit pressed I need to forward it to a thank you page within Wordpress.

I need to know what to place in the action field of the form to actually send it to the thank you page as currently it is going to a 404 page even though the browser shows that the URL is the correct URL for the thank you page.

There is quite a bit of text and formatting already in the form so I do not want to take it to a Wordpress plugin such as Contact 7.

Answers (3)

2010-01-28

seano answers:

As you suggested change the field to <input name="xxxx" type="text" id="xxxx"> where xxxx is not the word name and then place your URL in the action field.

2010-01-27

Dan Davies answers:

If it's just a standard PHP form, then the action field of the form attribute will be telling the form which file to process when the form is submitted.

Within the PHP code for the form, after the mail has been sent, you'll want to add the following line of code:

<?php header('Location: http://www.thankyou.page/'); ?>

This should work, but it depends on how your form is written. If you paste the code for it here then we could probably provide more accurate instruction. Although, technically this isn't a WordPress question ;)


Kirk O'Connor comments:

Sorry this re-directs to the same page not the new page.

I found the answer myself by doing a bit more research on wordpress.org.

The problem was one of the fields in the form was as follows:-

<input name="name" type="text" id="name">

Wordpress does not like "name".

Once I changed "name" to "f_name" the form posted to the thank you page immediately.

So it did turn out to be a Wordpress specific issue as I originally suspected.

2010-01-27

Casey Nix answers:

Or you could insert the following into the form HTML ... so whenever the form is processed it redirects to where you specify.

<input name="redirect" value="http:://wwwpathto.com/thanks/" type="hidden" />

Then, if you use permalinks in WP, you can just simply create a page named "Thanks" that the form will redirect to.

I've used this method on a number of occasions.


Kirk O'Connor comments:

Same here: this re-directs to the same page not the new page.

I found the answer myself by doing a bit more research on wordpress.org.

The problem was one of the fields in the form was as follows:-

<input name="name" type="text" id="name">

Wordpress does not like "name".

Once I changed "name" to "f_name" the form posted to the thank you page immediately.

So it did turn out to be a Wordpress specific issue as I originally suspected.