Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

TheReef

macrumors 68000
Original poster
Sep 30, 2007
1,888
167
NSW, Australia.
Hi all,
Haven't ran into this one before.
I have been able to send data using POST to URLs with GET variables in them successfully.

eg
Code:
<form action = "www.mysite.com?page=home">



But when sending variables using GET it overwrites the variables I've hard coded into the form action.


Any ideas? (I'm hoping it's something simple, preferably not using Javascript to set the URL).
Thanks for any help!
 
Code:
<form action = "www.mysite.com">
<input type="hidden" name="page" value="home" />

Would be the lazy way to handle it ;)
 
Code:
<form action = "www.mysite.com">
<input type="hidden" name="page" value="home" />

Would be the lazy way to handle it ;)

I feel so stupid :p
I was thinking there'd be a trick to avoid overwriting… :p

Thanks!

(Continuing the question - is there a quick way if the URL variables are not known?)
 
With GET, the query string is not sent with the action. Meaning, you need to use hidden fields for all the additional URL arguments. Then they show up in the URL on the submit.

To prevent users from knowing your GET variables, process then encrypt all arguments and values using sha1(), pass the encrypted string using a hidden form field with name set as "setvariables" or whatever, and value set as the encrypted string. Then on the page handling the form submission, decrypt $_GET['setvariables'] and split into an array using ? or & as separators and you've got your arguments back.

-jim
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.