HELP W/ PHP Session Login App

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • neilphan@gmail.com

    HELP W/ PHP Session Login App

    Hi Guys,
    Please HELP! I'm new to PHP and would like to get your professional
    help!


    I"m writing simple and small login app using php session variable. I
    have 3 php scripts. The first is just a simple php form, login.php,
    that passes the variables to auth.php.


    Auth.php just validates that the username and password is correct. If
    they match, i will set the php session,


    $_SESSION['logon'] = "ok", then redirect the user to anothor page,
    ADMIN.PHP

    ADMIN.PHP:
    <?
    session_start() ;


    if ($_SESSION['login'] != "ok")
    header("Locatio n: login.php");
    else
    /* do some stuff 8/
    ?>

    My code works well on the login.php and auth.php. But for some reason,
    when I get to ADMIN.PHP, it says that they it has an "UNDEFINED INDEX,
    LOGIN".


    Can anyone help me or have a sample php program that uses sessions for
    login?
    Much Help would be appreciated.


    Thanks in advance,
    PHP NOOBIE

  • Tim Van Wassenhove

    #2
    Re: HELP W/ PHP Session Login App

    On 2005-01-27, neilphan@gmail. com <neilphan@gmail .com> wrote:[color=blue]
    > Please HELP! I'm new to PHP and would like to get your professional[/color]

    If you give us professional pay :p
    [color=blue]
    >
    > Auth.php just validates that the username and password is correct. If
    > $_SESSION['logon'] = "ok", then redirect the user to anothor page,[/color]

    j> ADMIN.PHP:[color=blue]
    > if ($_SESSION['login'] != "ok")[/color]

    Notice that login != logon.

    But before you check the value in the 'login'/'logon' key of the array,
    you might want to use http://www.php.net/array_key_exists to make sure
    there is such a key (and value).

    if (!array_key_exi sts('logon', $_SESSION) || $_SESSION['logon'] != 'ok')
    {
    // don't know how well browsers support redirection with a relative
    // uri - http://www.ietf.org/rfc/rfc3986.txt
    header("Locatio n: login.php");
    }



    --
    Met vriendelijke groeten,
    Tim Van Wassenhove <http://www.timvw.info>

    Comment

    • sujee

      #3
      Re: HELP W/ PHP Session Login App

      Better if u can improve ur login script.
      problem is if the connected user keep the browser after logout without
      closing we can go to the other pages from ur auth.php. bec IE will
      supply the supplied passwo and username. use some query string in auth
      page relating with session ID and check it in the auth page. and after
      logout regenerate new session id. so if another user back, he can`t
      relate new sessionid with previous query string.

      Comment

      • Admin TreeNet

        #4
        Re: HELP W/ PHP Session Login App

        In article <1106797065.835 654.303030@c13g 2000cwb.googleg roups.com>,
        neilphan@gmail. com says...[color=blue]
        > Hi Guys,
        > Please HELP! I'm new to PHP and would like to get your professional
        > help!
        >
        >
        > I"m writing simple and small login app using php session variable. I
        > have 3 php scripts. The first is just a simple php form, login.php,
        > that passes the variables to auth.php.
        >
        >
        > Auth.php just validates that the username and password is correct. If
        > they match, i will set the php session,
        >
        >
        > $_SESSION['logon'] = "ok", then redirect the user to anothor page,
        > ADMIN.PHP
        >
        > ADMIN.PHP:
        > <?
        > session_start() ;
        >
        >
        > if ($_SESSION['login'] != "ok")
        > header("Locatio n: login.php");
        > else
        > /* do some stuff 8/
        > ?>
        >
        > My code works well on the login.php and auth.php. But for some reason,
        > when I get to ADMIN.PHP, it says that they it has an "UNDEFINED INDEX,
        > LOGIN".
        >
        >
        > Can anyone help me or have a sample php program that uses sessions for
        > login?
        > Much Help would be appreciated.
        >
        >
        > Thanks in advance,
        > PHP NOOBIE
        >[/color]

        I have a compact login package available a

        (I can zip it if you need that, RAR can read as-is).

        At present it uses MySQL to produce the first auth and stores its state
        in _SESSION.

        Modify it if you want.

        --
        AJ
        Treehouse Networks abuse@

        Comment

        Working...