56
I am installing a Chatroom and Instant Messenager program and I am trying to use XOOPS membership's database so that the chatroom and IM can put there user name automatically in the (NickName) field, rather than have the members type it in and hit the submit button.
I am using a php file:
<?php
//BUDDYLIST.PHP//
$DB_USR = "myDataUser";
$DB_PWD = "******";
$DB_NAME = "myDataName";
$DB_HOST = "localhost";
$db = mysql_connect($DB_HOST, $DB_USR, $DB_PWD)
or die ("Could not connect to database");
mysql_select_db($DB_NAME, $db);
if ($request=="add"){
$query2 = "INSERT INTO `buddylist`(`user`,`buddy`) VALUES('$user','$buddy')";
$result = mysql_query($query2);
if (!$result) {
die('Invalid query: ' . mysql_error());
}
}
if ($request=="remove"){
$query2 = "DELETE FROM `buddylist` WHERE user='$user' and buddy='$buddy'";
$result = mysql_query($query2);
if (!$result) {
die('Invalid query: ' . mysql_error());
}
}
[color=CC0000]$query3 = "SELECT `buddy` FROM `buddylist` WHERE user='$user_username'";[/color]
$result3 = mysql_query($query3);
$numofrows=mysql_num_rows($result3);
for($ii=0;$ii<$numofrows;$ii++)
{
mysql_fetch_row($result3);
if($ii==$numofrows-1)
{
$budy.=mysql_result($result3,$ii,"buddy");
}
else
{
$budy.=mysql_result($result3,$ii,"buddy").",";
}
}
echo("$buddy");
?>
And to find the username and their ID the following file:
<?
include("connect.php");
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="xoops.css" type="text/css">
</head>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="578" border="0" cellspacing="0" cellpadding="0" align="center" height="100%">
<tr>
<td class="head_txt" valign="top" height="20">welcome</td>
</tr>
<tr>
<DIV align=center>
<br />
<!--<applet NAME="MyChat Module" CODEBASE="http://www.MyWebPage/Classes/"
CODE="com.net.chat.client.ChatApplet" WIDTH="200" HEIGHT="100" ALIGN="middle"
ARCHIVE="Client_9_0_1_0.jar MAYSCRIPT">
<param name="siteID" value="577">
<param name="cabbase" value="Client_9_0_1_0.cab">
<param name="textcolor" value="000000">
<param name="browserClose" value="false">
<param name="WindowHeight" value="500">
<param name="WindowWidth" value="500">
<param name="background" value="FFFFFF">
<param NAME="BuddiesTab" value="true">
<param name="openProfileURL" value="true">
[color=CC0000]<param name="nickname" value=<? echo ("$user_username"); echo(">");
echo("<PARAM NAME=buddyList VALUE="); include("buddylist.php"); echo(">"); ?>
<param name="url" value="http://www.MyWebPage/userinfo.php?viewuser=<? echo $user_userid; ?>">[/color]
This site requires a Java compatible web browser to run.
If you can see this message you need to download Java free from
<a href="http://www.java.com/en/download/windows_automatic.jsp" target="_blank"> this website</a>.
</applet>-->
</DIV></td></tr></table></td></tr></table></td></tr>
<map name="Map">
<area shape="rect" coords="38,2,114,16" href="contact.htm">
<area shape="rect" coords="169,3,203,16" href="help.htm">
<area shape="rect" coords="267,2,325,17" href="logout.htm">
</map>
</body>
</html>
but I am not sure if the (WHERE user='$xoops_username'") is the right snippet to use to find the XOOPS username. Should it be just (WHERE user='$user'")? The items in
RED are is script I was concern about.