well it's just that i want to display the current loged user
like welcome: username so i put this together
<?php
mysql_connect("$host","$user","$pass") or die(mysql_error());
mysql_select_db("$db") or die(mysql_error());
$data = mysql_query("select username from $table") or die(mysql_error());
$info = mysql_fetch_array($data);
if(!session_is_registered('loged')){
echo('Bienvenido : Invitado');
}else{
echo('Bienvenido : '.$info['username']);
}
?>
but if i login with the last username or any other it just return the user of the first row on the database.
a little help?
thanks by the way x)
user online }/
Started by hk_, Jul 14 2007 07:02 AM
6 replies to this topic
#1
Posted 14 July 2007 - 07:02 AM
#2
Posted 14 July 2007 - 12:00 PM
Look up on some basic user system scripts.
You problem is you aren't selecting the logged in user. This is how you would do it as an example query.
Where $username is the currently logged in person's username, taken from their cookie, or session data.
Or you could select by the user's id, which is probably more reliable.
Once again, simply look up your average member system and you'll see it all in there.
You problem is you aren't selecting the logged in user. This is how you would do it as an example query.
SELECT * FROM `members` WHERE `username` = '$username'
Where $username is the currently logged in person's username, taken from their cookie, or session data.
Or you could select by the user's id, which is probably more reliable.
Once again, simply look up your average member system and you'll see it all in there.
#3
Posted 14 July 2007 - 03:25 PM
thanx a lot x)
#4
Posted 17 July 2007 - 11:33 AM
<?php
// add you're database connect file here...
$query = mysql_query("SELECT * FROM `table_name` WHERE `username` = '".$_SESSION['s_username']."'") or die("MySql Error: ".mysql_error() );
$row = mysql_fetch_array($query);
$onoff = $row['status'];
if ($onoff == 'Online') {
echo "Online";
}else{
echo "Offline";
}
?>
Now you're going to have to do a little editing, but that's what I used and it works.
// add you're database connect file here...
$query = mysql_query("SELECT * FROM `table_name` WHERE `username` = '".$_SESSION['s_username']."'") or die("MySql Error: ".mysql_error() );
$row = mysql_fetch_array($query);
$onoff = $row['status'];
if ($onoff == 'Online') {
echo "Online";
}else{
echo "Offline";
}
?>
Now you're going to have to do a little editing, but that's what I used and it works.
#5
Posted 17 July 2007 - 03:13 PM
Umm, Derek, i don't know if you noticed or not, but it appears as though he has already gotten it working.
#6
Posted 17 July 2007 - 09:25 PM
Nope, but you never know when someone will be lazy and just copy and paste then edit it
Plus, I can do what I want as long as it's within regulations.
#7
Posted 17 July 2007 - 10:14 PM
jeje thnx for the script im just having troubles with the sessions and frames xD
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users
