Home : Products : Gossamer Links : Discussions :

Products: Gossamer Links: Discussions: Re: [Andy] getting user information in PHP?: Edit Log

Here is the list of edits for this post
Re: [Andy] getting user information in PHP?
Tanks very much once more Andy!

The result is neither nice nor neat but works for me and is maybe of use for somebody.
Code:
<?php
$link = mysql_connect('localhost', 'user', 'pass');
$db_selected = mysql_select_db('database', $link);
if (!$link) {
die('not able to connect: ' . mysql_error());
}
$session_id = $_COOKIE['s'] ? $_COOKIE['s'] : '';
if ($session_id) {
$result = mysql_query("select * from glinks_Sessions where session_id = '$session_id'");
if (mysql_num_rows($result) == 1) {
while ($row = mysql_fetch_assoc($result)) {
$session = $row;
$expiry_time = $row['session_date'] + ($row['session_expires'] * 60 * 60);
}
}
}
if ($session AND $expiry_time > time()) {
$result = mysql_query("select * from glinks_Users where Username = '$session[session_user_id]'");
if (mysql_num_rows($result) == 1) {
while ($row = mysql_fetch_assoc($result)) {
$USER = $row;
}
}
}

echo "$USER[Username] ";//test
?>

Regards

n || i || k || o

Last edited by:

el noe: Mar 30, 2011, 9:30 AM

Edit Log: