Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: echo user name

  1. #1
    New Coder
    Join Date
    Sep 2005
    Posts
    42
    Thanks
    4
    Thanked 0 Times in 0 Posts

    echo user name

    hey guys im having a problem trying to echo the user that is logged in in the login script my client has.

    any body know login manager v3?

    if not it does not mater.

    so i have tried with echo $username but after it tells me undefined variable..

    i need to know were to start with this when you already have a script made up..

    cause what is confusing me is how will it know witch user is logged in?

    in this script.there is the form that referes to :

    Code:
    <?
    
    
    setcookie ("LMUSERNAME", $_POST['username']);
    setcookie ("LMPASSWORD", $_POST['password']);
    
    include_once ("auth_member.php");
    include_once ("admin/authconfig.php");
    
    $username = $_POST['username'];
    $password = $_POST['password'];
    
    $Auth = new auth();
    $detail = $Auth->authenticate($username, $password,$dbhost,$dbusername,$dbpass,$dbname);
    if (($detail==0)||($detail['uname'] == $adminusername))
    {
    ?><HEAD>
    <SCRIPT language="JavaScript1.1">
    <!--
    location.replace("<? echo "$failure"; ?>");
    //-->
    </SCRIPT>
    </HEAD>
    <?
    }
    else
    {
    $connection = mysql_connect($dbhost, $dbusername, $dbpass);
    $SelectedDB = mysql_select_db($dbname);
    $result = mysql_query("select distinct welcome from authuser where uname='$username'");
    while($row = mysql_fetch_array($result, MYSQL_NUM)) {
    $v_welcome=$row[0];
    }
    if ($v_welcome=='1'){
    mysql_query("update authuser set welcome='0' where uname='$username'");
    mysql_close($connection);
    echo "<meta http-equiv=\"refresh\" content=\"0; URL=$welcome\">";
    exit;
    }
    else {
    mysql_close($connection);
    echo "<meta http-equiv=\"refresh\" content=\"0; URL=$success\">";
    exit;
    }
    
    }
    ?>
    
    
    witch calls
    [php]
    <?
    
    
    class auth{
    // AUTHENTICATE
    function authenticate($username, $password,$dbhost,$dbusername,$dbpass,$dbname) {
    $enpass=base64_encode("$password");
    $query = "SELECT * FROM authuser WHERE uname='$username' AND passwd='$enpass' AND status <> '0'";
    $UpdateRecords = "UPDATE authuser SET lastlogin = NOW(), logincount = logincount + 1 WHERE uname='$username' and status='1'";
    $connection = mysql_connect($dbhost, $dbusername, $dbpass);
    $SelectedDB = mysql_select_db($dbname);
    $result = mysql_query($query);
    $numrows = mysql_num_rows($result);
    $row = mysql_fetch_array($result);
    // CHECK IF THERE ARE RESULTS
    if ($numrows == 0) {
    return 0;
    }
    
    else {
    
    $Update = mysql_query($UpdateRecords);
    return $row;
    }
    } // End: function authenticate
    
    
    function page_check($username, $password,$dbhost,$dbusername,$dbpass,$dbname) {
    $enpass=base64_encode("$password");
    $query = "SELECT * FROM authuser WHERE uname='$username' AND passwd='$enpass' AND status <> '0'";
    $connection = mysql_connect($dbhost, $dbusername, $dbpass);
    $SelectedDB = mysql_select_db($dbname);
    $result = mysql_query($query);
    $numrows = mysql_num_rows($result);
    $row = mysql_fetch_array($result);
    if ($numrows == 0) {
    return false;
    }
    else {
    return $row;
    }
    } // End: function page_check
    
    
    
    } // End: class auth
    ?>

  • #2
    New Coder
    Join Date
    Sep 2007
    Location
    US
    Posts
    88
    Thanks
    4
    Thanked 4 Times in 4 Posts
    make sure you aren't inside of a function while echoing, if so you need to make the $username global.

    I can't really read the code well, so I'll be a little longer with a solid answer, next time please you the [ PHP] tag next time.

    Right, so I've looked at the code some more, where are you trying to echo the user name?
    I don't see anything regarding the output of the name.
    Last edited by Digicoder; 01-21-2008 at 07:45 PM.
    I need to find a book about all this stuff. God, thats gonna be one big book!

    http://www.gamezftw.com
    Play On!


  •  

    Posting Permissions

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