0

I have a custom form in one of my wordpress pages(this page uses a custom template)-

 <form action="www.mysite.com/custom-page-2" method="post">
 . 
 .
 .
 </form>

Now the problem is that on submitting the browser shows the url "www.mysite.com/custom-page-2" in the address bar but shows a 404 page not found error. I read other solutions which ask to use action attribute for the same form page or use ajax or jquery. But my question is that why cant we use this method like normal php. What am I missing?

hakre
200k55 gold badges453 silver badges865 bronze badges
asked Sep 27, 2011 at 16:51
1
  • 1
    I think you forgot the "http://". The url must be "mysite.com/custom-page-2". Commented Sep 27, 2011 at 16:56

2 Answers 2

1

Try changing the action to: http://www.mysite.com/custom-page-2

UPDATE

After a little bit of digging it seems you need to set your action to an empty string, and redirect to the page you want during the form submission handler.

Try following steps 1 - 3 of this answer but instead of redirecting back to the same page, redirect to the page you want to go to.

Hope that helps

answered Sep 27, 2011 at 16:55
Sign up to request clarification or add additional context in comments.

3 Comments

i wish the soln had been so simple ;| ...tried every possible combination...it has something to do with the way wordpress handles the request urls...
Seems Wordpress form handling is a bit weird, I've updated the answer above with some more info
I had read the answer u mentioned...just thought someone might know why it has to be this way and not the way I have asked...
0

The problem is if you use general values for your "name" attribute it surprisingly fails(example- name="name")...just prefix it with some unique name...maybe wordpress uses these names itself and causes clashes..

answered Oct 2, 2012 at 19:46

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.