I have a php script the generates links where-by the URL is very long (too long for IE to handle infact) such as www.somesite.co.uk/here/query?foo=bar&bar=foo&..... where somesite.co.uk gets the values (which I can’t change to post).
So in my index.php:
echo "<a href='$url'>".$link."</a>";
All works fine for values of $url that are under the limit the page is seen as expected however if over the limit the data on the page is truncated.
I created this long_url_test.php script and it’s loads the page as expected for long values of $url
<?php
header('Location: $url');
?>
I need help putting this all together, something like:
index.php:
echo "<a href='long_url_test.php'>".$link."</a>"; # and POST $url to script
long_url_test.php:
<?php
$url=$_POST['url']
header('Location: $url');
?>
Where the link displayed on index.php posts the url to long_url_test.php which fetches the actual required page, or indeed is there a better/easier way I should do this?
Why are you generating such ridiculously long URLs? At this point you’re clearly missing out on a better solution like sessions.
If we just want to slap a bandaid on the solution:
Slightly better: Take whatever data you want to pass and run it through
base64_encode(serialize($your_data))and see if you can embed that in the URL without running into the length limit. If you have Zlib installed/enabled you can throw agzcompress()in there too.Still, I have a very hard time imagining that there is not a far simpler/better solution where your data stays server-side.