Is it possible to redirect to another page, say add.php with the request that were sent to the original page.
Say I have a file: form.html that has a post form
Now I submit this to form.php.
I want form.php to redirect the request to add.php so that add receives the same POST parameteres as form.php
this is done so that form.php can analyze a hidden field called action and depending on its value redirect to add.php or edit.php . I know this can be done in javascript by changing the form.action attribute. I am wondering if it is possible on server side
You can simply require_once inside a switch or if block.
If you really need actual redirection (i.e. you want the user to know where they were redirected to), you may need to send a ‘fake’ intermediate page, with an auto-submitting (via javascript) form full of hidden inputs.
The reason is right in the HTTP spec: