...

View Full Version : is it possible to hide $_GET['']; from URL



Dan13071992
01-05-2012, 02:40 AM
just as the title asks, is it possible to hide the $_GET['']; from the url, for example:

instead of:


http://test.com/index.php?page=title


is it possible to make it just show index.php?

Spookster
01-05-2012, 02:46 AM
Assuming this is coming from a form then yes use $_POST otherwise use sessions to pass the parameters.

Dan13071992
01-05-2012, 02:48 AM
no its not coming from a form, im using this:



<?php } if ($crew != "0" && $playercrew->owner == $fetch->username) {



if (empty($_GET)) {
include('crewmembers.php');

}

if (isset($_GET['page'])) {



switch ($_GET['page']) {

case 'members':
include('crewmembers.php');
break;
case 'hq':
include('crewhq.php');
break;
case 'apps':
include('crewapps.php');
break;
case 'info':
include('crewinfo.php');
break;
case 'alt':
include('crewalt.php');
break;
case 'donate':
include('crewdonate.php');
break;
case '':
include('crewblank.php');
break;
}

}
}
?>


i was just wondering if it would work without showing the ?page=*

Spookster
01-05-2012, 03:03 AM
If you are going to use $_GET then the parameter has to exist in the URL otherwise there is nothing to "get". Your only option would be to write that parameter to a session where that parameter is being set at and then read it from the session when you need to use it.

Microsuck
01-05-2012, 04:15 AM
Spook, do you think something could be done to the GET URLS with mod_rewrite?

devinmaking
01-05-2012, 08:36 AM
Spook, do you think something could be done to the GET URLS with mod_rewrite?

you can change the names with htaccess and them call then in like this.

htaccess code:


RewriteRule ^pagename/pageoption/?$ pagename/.php?pageoption=whatever [L]

or if its variable based:
([A-Za-z0-9-]+)

RewriteRule ^pagename/([A-Za-z0-9-]+)/?$ pagename/.php?pageoption=$1 [L]


if(isset($_REQUEST["result"]) && $_REQUEST["result"] == "whatever"){

//do something

}

tangoforce
01-05-2012, 01:31 PM
Using mod re-write however does kind of presume that you know all the url variations etc.

The only other thing you could do is use some complex javascript and convert your links to actually submit a hidden form instead.

That could be a lot of work for you though.

Fou-Lu
01-06-2012, 12:12 AM
you can change the names with htaccess and them call then in like this.

htaccess code:


RewriteRule ^pagename/pageoption/?$ pagename/.php?pageoption=whatever [L]

or if its variable based:
([A-Za-z0-9-]+)

RewriteRule ^pagename/([A-Za-z0-9-]+)/?$ pagename/.php?pageoption=$1 [L]


if(isset($_REQUEST["result"]) && $_REQUEST["result"] == "whatever"){

//do something

}

This doesn't answer the question; this takes a 'friendly' display and maps it to the appropriate query string. In either case, the same data is available in the url.
So to answer the OP, no you can't since that is illogical. As spooks mentioned, if you need to look something up provided by a user, they have to provide it to you either explicitly with a post or get, or implicitly with other decisions creating a session or cookie.
There is also no way to alter the viewed url; browsers are controlled by the client, not the server.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum