I have a post html form, and the action is index.php, which is the websites main page. I never actually have index.php in the address bar, since links to "/" go to it, and even if I did, it would be website.com/home(/), since I use rewrite rules. So basically, the user should never see index.php. However, the form submit doesn't work if the action isn't spefically index.php, "/" doesn't work, even though that resolves to index.php. Any ideas on how to get around this?
+2
A:
Don't specify the action. If the post is to the page they're on, the default action of the form is to post to that.
John Cavan
2009-10-26 01:41:49
But I need to go to /sent, or index.php?page=sent.. and current page!= sent, so how would I do that?
Mk12
2009-10-26 01:50:38
form action="?page=sent"
John Cavan
2009-10-26 10:33:46
no because I want the address bar to show website.com/sent (which with a rewrite rule actually goes to index.php?page=sent), but I just realised I don't need this. In index.php instead of checking for page=sent, I'll check if the post variables (from, subject, body) are there.
Mk12
2009-10-26 12:13:57
You should always specify an action on your form elements. The w3c spec lists it as required, so this solution uses some courtesy (but non-standard) browser behavior to work.
grossvogel
2010-05-07 23:24:23