techker Posted January 21, 2008 Share Posted January 21, 2008 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 : <? 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 [code=php:0] <? 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 ?> Link to comment https://forums.phpfreaks.com/topic/87084-user-echo/ Share on other sites More sharing options...
Barand Posted January 21, 2008 Share Posted January 21, 2008 Have you tried echoing out the session vars to see if it is stored in one of those? echo '<pre>', print_r($_SESSION, 1), '</pre>'; Link to comment https://forums.phpfreaks.com/topic/87084-user-echo/#findComment-445399 Share on other sites More sharing options...
techker Posted January 21, 2008 Author Share Posted January 21, 2008 it gives me an undifined variable <? echo '<pre>', print_r($_SESSION, 1), '</pre>'; ?> Notice: Undefined variable: _SESSION in h:\lfnc\easyphp1-8\www\utilisateur.php on line 31 Link to comment https://forums.phpfreaks.com/topic/87084-user-echo/#findComment-445403 Share on other sites More sharing options...
Barand Posted January 21, 2008 Share Posted January 21, 2008 Call session_start() first Link to comment https://forums.phpfreaks.com/topic/87084-user-echo/#findComment-445405 Share on other sites More sharing options...
techker Posted January 21, 2008 Author Share Posted January 21, 2008 i got it going thx! <? $USERNAME = $_COOKIE['LMUSERNAME']; ?> Link to comment https://forums.phpfreaks.com/topic/87084-user-echo/#findComment-445408 Share on other sites More sharing options...
techker Posted January 21, 2008 Author Share Posted January 21, 2008 no i just have to make the echo look nicer..lol Link to comment https://forums.phpfreaks.com/topic/87084-user-echo/#findComment-445411 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.