use of variables in different pages

Discussion in 'PHP' started by steyr, Jul 31, 2007.

  1. #1
    Hy!

    I have created a login for a php application. The user is forced to enter a username and password. This username and password is used to connect to a database. If this is possible the login was successful. Now I want to use this variables ($username, $password) also in other files that belong to this application.
    So how am I able to get variables that are defined in other pages of the script? It seems a simple task but I could not really find out searching my manuals!

    thanks for help
     
    steyr, Jul 31, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
  3. nagasharmi

    nagasharmi Peon

    Messages:
    28
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    first file
    session_start()
    $_SESSION['username']=$username;
    $_SESSION['password']=$password;

    the following sentence will use in another file.
    echo $_SESSION['usernname'];
    i am not sure try it
     
    nagasharmi, Jul 31, 2007 IP
  4. steyr

    steyr Guest

    Messages:
    27
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hello!

    Thanks a lot for your help! It works great!
     
    steyr, Aug 1, 2007 IP