Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Regular Coder
    Join Date
    Dec 2010
    Location
    Kent, UK
    Posts
    573
    Thanks
    23
    Thanked 10 Times in 10 Posts

    is it possible to hide $_GET['']; from URL

    just as the title asks, is it possible to hide the $_GET['']; from the url, for example:

    instead of:

    Code:
     http://test.com/index.php?page=title
    is it possible to make it just show index.php?
    http://360-tactics.co.uk/forum/index.php

    Crime-Wave

    please post your code wrapped in tags
    please post your PHP wrapped in tags

  • #2
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Assuming this is coming from a form then yes use $_POST otherwise use sessions to pass the parameters.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #3
    Regular Coder
    Join Date
    Dec 2010
    Location
    Kent, UK
    Posts
    573
    Thanks
    23
    Thanked 10 Times in 10 Posts
    no its not coming from a form, im using this:

    PHP Code:
    <?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=*
    http://360-tactics.co.uk/forum/index.php

    Crime-Wave

    please post your code wrapped in tags
    please post your PHP wrapped in tags

  • #4
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    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.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #5
    Regular Coder Microsuck's Avatar
    Join Date
    Oct 2011
    Location
    127.0.0.1
    Posts
    123
    Thanks
    44
    Thanked 5 Times in 5 Posts
    Spook, do you think something could be done to the GET URLS with mod_rewrite?
    PHP Code:
    <?php echo "Microsuck says hi!"?>

  • #6
    Regular Coder
    Join Date
    Oct 2011
    Posts
    237
    Thanks
    11
    Thanked 5 Times in 5 Posts
    Quote Originally Posted by Microsuck View Post
    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:

    Code:
    RewriteRule ^pagename/pageoption/?$ pagename/.php?pageoption=whatever [L]
    or if its variable based:
    ([A-Za-z0-9-]+)
    Code:
    RewriteRule ^pagename/([A-Za-z0-9-]+)/?$ pagename/.php?pageoption=$1 [L]
    PHP Code:
    if(isset($_REQUEST["result"]) && $_REQUEST["result"] == "whatever"){

    //do something



  • #7
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,327
    Thanks
    60
    Thanked 525 Times in 512 Posts
    Blog Entries
    4
    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.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • #8
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Quote Originally Posted by devinmaking View Post
    you can change the names with htaccess and them call then in like this.

    htaccess code:

    Code:
    RewriteRule ^pagename/pageoption/?$ pagename/.php?pageoption=whatever [L]
    or if its variable based:
    ([A-Za-z0-9-]+)
    Code:
    RewriteRule ^pagename/([A-Za-z0-9-]+)/?$ pagename/.php?pageoption=$1 [L]
    PHP Code:
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •