Redirect POST and URL at same time
Posted on 2003-03-09
I'm developing a simple class for doing basic editing on a MySQL table. By basic, I mean edit the values in a row, delete a row, or just view a row. My script creates an HTML table to display what's in the MySQL table. The last column in each row in the HTML table is a form with a dropdown box and some hidden variables. The action of each form is $PHP_SELF
I want to redirect the POST variables AND the browser to a new URL at the same time. If the user selects "edit" from the dropdown box, they should be redirected to edit.php and the hidden varables I mentioned need to be redirected as well. One of the hidden post variables edit.php uses is the primary key for the row that the user wishes to edit.
I need to do it this way because in the class I'm writing, the user can specify the URL to handle certian actions. You also get to specify the actions that get in the dropdown box. If I get this to work, it will make this class very flexible for my future projects. I'd also be willing to share it.
I need to use POST to keep the user from figuring out what info is beind sent by looking at the URL in their brower's address bar. For security reasons, I've disabled GET and turned off global vars.
I've seen suggestions that involve using urlencode... but this won't work since a user can just copy and paste the encoded URL into another program that uses urldecode. Not safe.
I've seen solutions on the web that redirect the POSTed variables. I also know how to redirect browsers with the use of php's header tag. What I need is a solution that encompases both of these at the same time.
Thanks in advanced for your help!