Ok, so you have a link to something like:
http://www.domain.com/?test1=whatever&test2=whoever&test4=whichever
and then you are wanting it to actually call back to:
http://www.domain.com/ with all those values in $_POST instead of $_GET correct?
You may have already considered these, and you may be ok with them, but just wanted to point out the following if you haven't:
1. Your method required the user to have javascript, while these days, not such a big thing, as by default most browsers have it and it is enabled (even mobile browsers), it is good not to rely on something Client side. Also see #3
2. People will not be able to bookmark these pages, as they will be bookmarking the home page without the data being passed to it.
3. Also, if you have any concern for SEO, Search engines will see the content on all the pages using this as just a form. They will not post and follow the form on to the actual data.
4. Navigation (being hitting back) will be a pain. When they hit back it will technically take them back to the form which will resubmit again.
So all that being said, if you still need something to do this, here is a solution that solves #1 above #2,3,&4 without having the final page being a unique URL where you do not have to kick them from one URL to the other, you won't be able to avoid.
index.php:Code: Select all
<?php
session_start();
if (count($_GET)>0) {
$_SESSION['getdata'] = $_GET;
header('Location: /');
exit;
}
if (isset($_SESSION['getdata'])) {
if (is_array($_SESSION['getdata'])) { $_GET = $_SESSION['getdata']; }
unset($_SESSION['getdata']);
}
// Continue on with regular script
Once you get past this, $_GET will be populated just as if you didn't use something like this.
-Greg