PDA

View Full Version : is there a limit to url size?


heaps21
02-26-2004, 12:02 PM
I have a form, and the url has quite a few variables appended onto it. I am finding that it doesnt pass some variables that are towards the end of the url, or only bits of them. This made me think there is some sort of limit as to how much you can pass to a GET, anybody know if this is right and if so is there anything that can be done about it?
Cheers, Andy.

raf
02-26-2004, 01:28 PM
That is indeed correct.

Can't you use a POST-method instead of the GET-method?

heaps21
02-26-2004, 02:17 PM
hmmm, i could, although i reckon I can still use get but reduce the no. of variables and just get them back with another query in the next page.

raf
02-26-2004, 02:25 PM
Euh ... It's not the number of variables but the number of characters that determines the cutoff.

If you don't realy need to pass the variable-value pairs in the quertystring, then there is simply no reason to use the GET-method. POST is far more userfriendly + doesn't have the cutoff.

heaps21
02-26-2004, 02:41 PM
The page im working on isnt a form with inputs though - it just displays data so doesnt that mean I would have to put every variable into a hidden field to be able to access it with a post?

raf
02-26-2004, 03:09 PM
well, i don't know your concrete situation, but you could just as well store the values in sessionvariables or an session variab that is an array. So that they don't need to be dragged along over the client, and there is no risk of manipulation of the values, by the client. You could also store the complete querystring inside a variable and then explode it (see below) (or you couls store themin a textfile or db)

Or you could indeed store them all in hidden formfields or store the complete querystring as the value of one hidden formfield. You could then make then usable like

$varvalues = explode('&', $thevariable);
foreach ($varvalues as $varvalpair){
$pair = explode ('=',$varvalpair);
$$pair[0] = $pair[1];
}

After that, you can use them as like regular values.
For instance, if your initial $thevariable looked like 'product=test&item=5&quant=10
then the code above will transform it into 3 variables
$product (which value will be 'test')
$item (which value will be 5)
$quant (which value will be 10)

But dragging them along in the querystring should only be done i you can't avoid it ...

heaps21
02-26-2004, 04:07 PM
right I see, thanks for that!