Results 1 to 3 of 3

Thread: [RESOLVED] what's wrong hare

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2006
    Posts
    185

    Resolved [RESOLVED] what's wrong hare

    PHP Code:
    <?
    session_start();

    //if Null T1 and T2
    if((!$T1) || (!$T2)){
    echo  "<div id=\"Login_message\" style=\"color:red\">Invalid User or Password!</div>";
    include ('index.html');
    exit;
    }

    ?>
    it returns

    Invalid User or Password!
    "; include ('index.html'); exit; } else echo aaa; ?>

    why it returns the last line?
    Please Help

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: what's wrong hare

    A session does not make ordinary variables persist, but only the variables in the $_SESSION array. To fix, change your assignments to this:
    PHP Code:
    $_SESSION['T1'] = 'whatever';
    $_SESSION['T2'] = 'whatever'
    and access them like this:
    PHP Code:
    session_start();

    if (!isset(
    $_SESSION['T1']) || !isset($_SESSION['T2']))
      
    // do whatever 
    Note that the opening <? tag is deprecated, and you should use <?php instead.
    Also, you shouldn't ever use echo to output HTML in a production environment. There are much neater ways of doing it, such as templates.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Feb 2006
    Posts
    185

    Re: what's wrong hare

    Oh!
    no problem now
    It's working

Posting Permissions

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



Click Here to Expand Forum to Full Width