Multiple pages in one file

Discussion in 'PHP' started by kc3, Mar 7, 2006.

  1. #1
    There is a php file that has the pages selected using a simple if function like this
    But if you go to the following URL it does not the the contents of that if statement and just skips it.
    I realy have to know why this is happening.
     
    kc3, Mar 7, 2006 IP
  2. clancey

    clancey Peon

    Messages:
    1,099
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    0
    #2
    The material after the question mark in the URL is called the query strong. You access it as follows:

    $mode = strtolower(  $_SERVER["QUERY_STRING"] );
    Code (markup):
    In you case, it is going to return "mode=register"

    So your test becomes:

    if($mode == "mode=register")
    Code (markup):
    unless you split the query to find out what type it is and what it is. Your type becomes "mode" and what your are seeking is the "register" mode.
     
    clancey, Mar 7, 2006 IP
  3. LGRComp

    LGRComp Well-Known Member

    Messages:
    516
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    195
    #3
    Register globals is turned off on the server, as it should be. You have to access mode like so in your code:


    Of course you might want to do some checks about what is allowed in modes.
     
    LGRComp, Mar 7, 2006 IP
  4. kc3

    kc3 Peon

    Messages:
    857
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Oh okay, why thank you. :)
     
    kc3, Mar 7, 2006 IP
  5. clancey

    clancey Peon

    Messages:
    1,099
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    0
    #5
    $mode=$_GET['mode'] ;
    Code (markup):
    My oversight. There is always more than one way to skin a cat in PHP and perl.
     
    clancey, Mar 8, 2006 IP
  6. kc3

    kc3 Peon

    Messages:
    857
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Hm... How come when I put the $_GET in my file none of my tables are listing the users from my database anymore. It uses normal pagination and works fine without it. Also, why are the link on this page not working with IE it only works with Firefox :( Last time I checked IE was capable of showing links. wtf?
     
    kc3, Mar 8, 2006 IP
  7. clancey

    clancey Peon

    Messages:
    1,099
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Putting the line $mode = $_GET['mode']; in your file is not going to affect your ability to list users in the database; nor affect a browsers ability to render the page.

    When this happens, it suggests that you have a critical error in the file. Error reports should show up in your web broswer file. I also find it helpful to run pages I have just edited from the command line to see if they are generating errors.

    If the links are not showing, take a look at the source for the rendered page and make sure they are valid. This is just part of the normal write-run-debug cycle of program development. Programming takes patience and a good eye.
     
    clancey, Mar 8, 2006 IP
  8. kc3

    kc3 Peon

    Messages:
    857
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #8
    omg, lol, there was a mistake in one of the $_GET variables. That's why I was confused clancey, thanks for all your help :)
     
    kc3, Mar 8, 2006 IP
  9. clancey

    clancey Peon

    Messages:
    1,099
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    0
    #9
    You are most welcome. I am glad I could help.
     
    clancey, Mar 9, 2006 IP