another php question

Discussion in 'OT Technology' started by Mikey, Jul 16, 2003.

  1. Mikey

    Mikey This one, this form I hold now, so Wide eyed and h

    Joined:
    Oct 18, 2001
    Messages:
    23,118
    Likes Received:
    0
    Location:
    Baltimore
    I'm new to php and im going through our old programmers code since now i basically have to learn php in 24hours :rolleyes: below is the code and im trying to figure out what exactly "/index.php?show=98" is doing.

    PHP:
    <%
    include ( 
    'includes/reports.inc'   );
    include ( 
    'includes/functions.inc' );

        
    $glbl_err rawurldecode($glbl_err);
    // Added the "sleep" since currentUser was turning up "not set"
    // This seems to have solved the problem.


    if ( !session_is_registered "currentUser" ) ||
         !
    isbitset LAB_REPORT$currentUser->menumask ))
    {
        if ( !
    session_is_registered "currentUser" ))
        {
            
    $webname $base_host '/index.php?show=98';
            
    header "Location: " $webname );
            exit;
        }
        else
        {
            print(
    "<html><header>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\n");
            print(
    "<meta http-equiv=\"Cache-Control\" content=\"max-age=0\">\n");
            print(
    "<meta http-equiv=\"Content-Style-Type\" content=\"text/css\">\n");
            print(
    "<link href=\"/mednexus.css\" rel=\"stylesheet\" type=\"text/css\">\n");
            print(
    "<title>MedNexus Lab Menu</title>\n<body class=\"mednexus\">");
            
    $section cSECT_LAB_MAIN;
            include( 
    'includes/header.inc');
            print ( 
    "<p class=\"announce\">\n" );
            print ( 
    "DAQReports is a billable service.<br>\n" );
            print ( 
    "Please have your administrator sign you up for this service or<br>\n" );
            print ( 
    "for  more details contact Antek's Sales department 1.800.359.0911 x3<br>\n" );
            print ( 
    "</p>\n" );
            print ( 
    "</body></html>");
        }
    }
    else
    {
        include ( 
    '/includes/daqreport.inc' );
    }
    %>
     
  2. Isn't that the page you are viewing?

    It's ID is 98?


    I think thats basically the same as saying "this is page 98, which will be shown in the browser address bar"

    look up at the address of this post, it is 726827.

    I dont know how it works, cause i just started with php, but it has something to do with that.
     
  3. Mikey

    Mikey This one, this form I hold now, so Wide eyed and h

    Joined:
    Oct 18, 2001
    Messages:
    23,118
    Likes Received:
    0
    Location:
    Baltimore

    i figured that much, but im wondering how it pulls as "98"
     
  4. I've been trying to figure that out too. The only problem is i haven't really found anyone who can explain it easily.

    If i find out i'll post it back here.
     
  5. crotchfruit

    crotchfruit Guest

    in the line "$webname = $base_host . '/index.php?show=98'; ", the 98 is hard coded. he's not retrieving that number from the url request. he's basically putting an http header in the http response that says "Location: [base]/index.php?show=98" no matter what the user entered as the show value.

    The Location header is used to redirect people to a new location.. so apparently he is redirecting requests for index.php to index.php?show=98. This seems a little silly to me.

    Edit: ok, i see. basically, if the currentUser variable is not registered in the session, he is redirecting the user to /index.php?show=98. my guess is that /index.php?show=98 displays some message telling the user to log in or something.
     
  6. Mikey

    Mikey This one, this form I hold now, so Wide eyed and h

    Joined:
    Oct 18, 2001
    Messages:
    23,118
    Likes Received:
    0
    Location:
    Baltimore

    actually if the user is not registered or logged in it bounces them down to the "Else" statement. The index.php?show=98 is if they ARE registered.
     
  7. crotchfruit

    crotchfruit Guest

    my guess got :Owned: :eek3: :eek3: :eek3: :eek3: :eek3:

    but what i said is still true, that the redirect occurs when currentUser is not registered in the session :big grin:
     
  8. Mikey

    Mikey This one, this form I hold now, so Wide eyed and h

    Joined:
    Oct 18, 2001
    Messages:
    23,118
    Likes Received:
    0
    Location:
    Baltimore

    :rofl: your the same fruitcake that :Owned: me in my other php post and you didn't recognize the "else" statement? :rofl: :fawk:
     
  9. crotchfruit

    crotchfruit Guest

    what are talking about? where in my above posts do i not recognize the 'else' statement?
     
  10. moomooloopoo

    moomooloopoo Guest

    :Owned:

    Edit: I'm 0wning both of you.
     
  11. crotchfruit

    crotchfruit Guest

    here is what happened as far as i can tell. you posted:

    Code:
    if ( !session_is_registered ( "currentUser" ) || 
         !isbitset ( LAB_REPORT, $currentUser->menumask )) 
    { 
      if ( !session_is_registered ( "currentUser" )) 
        { 
            $webname = $base_host . '/index.php?show=98'; 
            header ( "Location: " . $webname ); 
            exit; 
        } 
        else 
        { 
        ...
        }
    }
    else
    ...
    
    then i said,

    this is a true statement. your 'if' statement performs on the condition "( !session_is_registered ( "currentUser" ))" --> if the currentUser variable is not registered in the session.

    then you said,

    because i have no information on the relationship between the 'currentUser' variable and the login state of the user, i could only guess by the variable name that 'currentUser' would be defined if the user was logged in. therefore i made the guess that if the user not logged in [and that 'currentUser' was not defined], it would perform the code in the upper portion of the if clause. at no time did i ever "not recognize" the else statement.
     
  12. moomooloopoo

    moomooloopoo Guest

    :Owned:
     

Share This Page