...

View Full Version : echo user name



techker
01-21-2008, 07:31 PM
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
[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
?>

Digicoder
01-21-2008, 07:37 PM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum