Remember Username & Password

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
webgenius_coder
Forum Newbie
Posts: 2
Joined: Sat Mar 15, 2008 1:59 pm

Remember Username & Password

Post by webgenius_coder »

At present I'm using $_SESSION['UserName'] to create and store the login details. But I'm not able to access this session variable. Is there any way for the website to remember these details?

Code: Select all

$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
 
if($count==1){
    // Register $myusername, $mypassword and redirect to file "LoginOK.php"
    session_start();
    session_register("myusername");
    session_register("mypassword");
    $_SESSION['loginname'] = $myusername;
    //echo $_session['loginname'];
    header("location:index.php");
}
I'm using <?php echo $_session['loginname']; in index.php. Is there anything wrong with the code?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Remember Username & Password

Post by Christopher »

It needs to be:

Code: Select all

<?php
session_start();     // You must call this function before using $_SESSION. It loads the data into $_SESSION.
echo $_SESSION['loginname'];     // The name is all upper case
(#10850)
webgenius_coder
Forum Newbie
Posts: 2
Joined: Sat Mar 15, 2008 1:59 pm

Re: Remember Username & Password

Post by webgenius_coder »

arborint wrote:It needs to be:

Code: Select all

<?php
session_start();     // You must call this function before using $_SESSION. It loads the data into $_SESSION.
echo $_SESSION['loginname'];     // The name is all upper case
Thanks. Problem solved.
Post Reply