help in invite topic function

Started on the old forum in January 2010 · view the original in the archive · old links redirect here

7 replies · 442 views · started 16 years ago · 1 min read

2 participants
icedroplet1987 Senior · 258 posts #1

hello friends, i have made this topic invite function.. but i am only able to select only 1 username to send invite.. but i want my users to send invite to multiple users by seperating username with comas in txtboz..

if($action=="sendinvi"){
echo "<p align=\"left\">";
$pmtou = $_POST["usn"];
$who = getuid_nick($pmtou);
$whonick = getnick_uid($who);
addonline(getuid_sid($sid),"inviting users to topic","");
$byuid = getuid_sid($sid);
$tm = time();
$pmtext = "txt";
$dm = mysql_fetch_array(mysql_query("SELECT id FROM hfjgn_users WHERE name='".$unm."'"));
$res = mysql_query("INSERT INTO hfjgn_private SET text='".$pmtext."', byuid='".$byuid."', touid='".$who."', timesent='".$tm."'");

echo "<img src=\"images/ok.gif\" alt=\"O\"/>";
echo "PM was sent successfully to $whonick<br/><br/>";
echo parsepm($pmtext, $sid);
echo "<br/><br/><a href=\"121inbox121.php?action=disp\">Back to MailBox</a><br/>";
djlee Developer · 224 posts #2
if($action=="sendinvi"){
echo "<p align=\"left\">";
$usrs = explode(",",$_POST['usn']);
$insert = array();
addonline(getuid_sid($sid),"inviting users to topic","");
$byuid = getuid_sid($sid);
$tm = time();
$pmtext = "txt";

foreach($usrs as $pmtou)
 {
 $who = getuid_nick($pmtou);
 $insert[] = "('".$pmtext."'", '".$byuid."','".$who."','".$tm."')";
 }

$res = mysql_query("INSERT INTO hfjgn_private (text,byuid,touid,timesent) VALUES ".implode(",",$insert));

echo "<img src=\"images/ok.gif\" alt=\"O\"/>";
echo "PM was sent successfully to ".implode(", ",$usrs)."<br/><br/>";
echo parsepm($pmtext, $sid);

echo "<br/><br/><a href=\"121inbox121.php?action=disp\">Back to MailBox</a><br/>";

try something like that

icedroplet1987 Senior · 258 posts #3

thnx to reply mate.. it shows that it sent msg to all users what we wrote but only sending to 1st username still.

djlee Developer · 224 posts #4

since i dont use wap sources i cant test any of the code, the code is quite simple really , change

$res = mysql_query("INSERT INTO hfjgn_private (text,byuid,touid,timesent) VALUES ".implode(",",$insert));

to

print("INSERT INTO hfjgn_private (text,byuid,touid,timesent) VALUES ".implode(",",$insert));

In the code i gave and try it again, it should print out the sql statement, put that in this thread so i can have a look at wat the loop is producing, it should work as i use a similar method on another site for mass messaging

icedroplet1987 Senior · 258 posts #5

when i made changes as you said then INSERT INTO hfjgn_private (text,byuid,touid,timesent) VALUES ('txt', '2','322','1264102501'),('txt', '2','','1264102501'),('txt', '2','','1264102501')OPM was sent successfully to sterla , w0lverln3 , raghavan

djlee Developer · 224 posts #6

that means the touid isnt being set for the last 2 messages, that value is controlled by $who which in turn gets its value from getuid_nick($pmtou);.

I imagine either you are entering an invalid username or there is a problem with your getuid_nick function (or that function isnt doing what you think it does)

icedroplet1987 Senior · 258 posts #7

well 322 is the uid.. function getuid is ok as it selected ids.. but still not in this format 1 , 2 , 3 , 4 etc

djlee Developer · 224 posts #8

how do you know getuid function has gotten the id's, 322 is ONE of the id's, the id for sterla to be exact, it is not retrieving the id for the other two, and qute simply it looks like you are putting spaces after or before each comma which obviously means that the 2nd and 3rd user you send it too dont exist with the usernames provided as you have put spaces in there, put the mysql query back to how it was and in my code change

 $who = getuid_nick($pmtou);

too

 $who = getuid_nick(trim($pmtou));

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close