View Full Version : get/post using form with ?var= in url
04-21-2006, 05:19 AM
This isn't a big deal as it seems to be easy to work around... but...
If I'm using method="get" for a form tag, then it ignores anything after the ?... meaning "index.php?var=1" just makes the next page "index.php", ignoring the var=1 part.
However, a hidden input makes it easy enough to work around.
But... if I'm using method="post", then that seems to work WITH the ?var=1 part, where the url WOULD be index.php?var=1.
This is kinda puzzling. I haven't tested extensively, so I might be wrong.
Is this some kind of safety precaution so the ?var=1 doesn't conflict with an input of "var" later on?
What's up? :)
04-21-2006, 07:07 AM
Hmmm I'm not sure I understand your question- is your trouble just with the browser stripping the parameters off the URL on the next page after submission, versus you having trouble getting those parameters inside your PHP script (via $_GET)?
04-21-2006, 07:32 AM
If POST is method for form, the next URL DOES have ?var=1.
If GET is method for form, the next URL DOES NOT have ?var=1.
The php works fine.
04-21-2006, 10:53 AM
Hmmm I'm not sure I understand your questionI believe what djr33 is trying to describe is markup along the lines of:
<input name="control-name" type="text" value="">
<!-- ... -->
<input type="submit" value="Send">
When submitted, he expects a request to a URL such as:
However, the preset query string is being removed, creating a request for:
Whilst I agree that this is bad (though not wrong) behaviour - I think user agents should append the form data - it's common. Using hidden form controls is the most reliable approach.
04-23-2006, 05:00 AM
that's exactly what I'm saying.
so.. it's the browser, not php... makes sense.... it is the url you're sent to.. ok. not my coding either.. good.
So... basically, the form overrides the ending after the ?..., so with GET it does that, but POST doesn't override it.
and, yeah, seems weird. Any way around this? (yes, I've tried hidden values in the forms... that's fine...)
04-23-2006, 11:12 AM
Any way around this?Other than hidden controls, no. We just have to live with it.
04-23-2006, 08:08 PM
Alright. Well... easy enough.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.