PHP Code:
$username = $_GET['user'];
/*
I suggest changing this query to, then you will only need 1 query then 3
SELECT user.userid, user.usergroupid, userfield.field6
FROM vb_user AS user
LEFT JOIN vb_userfield AS userfield ON (userfield.userid = user.userid)
WHERE user.username = '" . mysql_escape_string($username) . "'"
*/
//added mysql_escape_string to protect against sql injection
$query = "SELECT userid FROM vb_user WHERE username='" . mysql_escape_string($username) . "'";
$result = mysql_query($query);
if(mysql_num_rows($result) > 0)
{
$row = mysql_fetch_row($result);
//this should be userid not 0, you can var_dump for debug if you aren't getting the value you want
$userid = $row['userid'];
//why not just select usergroupid from your first query?
$query = "SELECT usergroupid FROM vb_user WHERE userid='" . $userid . "'";
$result = mysql_query($query);
if(mysql_num_rows($result) > 0)
{
$row = mysql_fetch_row($result);
$group = $row[0];
//you can use a left join with your first query to get this value also
$query = "SELECT field6 FROM vb_userfield WHERE userid='" . $userid . "'";
$result = mysql_query($query);
if(mysql_num_rows($result) > 0)
{
$row = mysql_fetch_row($result);
$serial = $row[0];
echo "Username: " . $username . "<br>";
echo "Userid: " . $userid . "<br>";
echo "group: " . $group . "<br>";
echo "programid: " . $serial . "<br>";
}
}
}
else {
echo "Username: Invalid";
}