Jump to content


user online }/


6 replies to this topic

#1 hk_

    Young Padawan

  • Members
  • Pip
  • 52 posts
  • Gender:Male
  • Location:lost

Posted 14 July 2007 - 07:02 AM

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)

#2 Demonslay

    P2L Jedi

  • Members
  • PipPipPip
  • 970 posts
  • Gender:Male
  • Location:A strange world where water falls out of the sky... for no reason.
  • Interests:Graphic Design, Coding, Splinter Cell, Cats

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.

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 hk_

    Young Padawan

  • Members
  • Pip
  • 52 posts
  • Gender:Male
  • Location:lost

Posted 14 July 2007 - 03:25 PM

thanx a lot x)

#4 derek.sullivan

    Jedi In Training

  • Members
  • PipPip
  • 341 posts
  • Gender:Male
  • Location:Georgia
  • Interests:preaching, programming, music, friends, outdoors, moves, books

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. :(

#5 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

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 derek.sullivan

    Jedi In Training

  • Members
  • PipPip
  • 341 posts
  • Gender:Male
  • Location:Georgia
  • Interests:preaching, programming, music, friends, outdoors, moves, books

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 hk_

    Young Padawan

  • Members
  • Pip
  • 52 posts
  • Gender:Male
  • Location:lost

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