<TITLE>ARY discussion groups</TITLE>

<!

includeFile("../body");

$group=(int)$group;
$sgroup=(int)$sgroup;

$sock=msqlConnect();
if ($sock<0) {
   echo("<CENTER><TABLE WIDTH=500 BORDER=2 BGCOLOR=\"$color3\">\n");
   echo("<TR><TD>\n<BR><CENTER>$ERRMSG</CENTER><BR>\n</TD></TR>\n</TABLE>\n");
   exit(0);
   }

if (msqlSelectDB($sock, "discussion")<0) {
   echo("<CENTER><TABLE WIDTH=400 BORDER=2 BGCOLOR=$color3>\n");
   echo("<TR><TD>\n<BR><CENTER>$ERRMSG</CENTER><BR>\n</TD></TR>\n</TABLE>\n");
   exit(0);
   }

if (msqlQuery($sock, "SELECT * FROM group WHERE gid=$group")<0) {
   echo("<CENTER><TABLE WIDTH=400 BORDER=2 BGCOLOR=$color3>\n");
   echo("<TR><TD>\n<BR><CENTER>$ERRMSG</CENTER><BR>\n</TD></TR>\n</TABLE>\n");
   exit(0);
   }
$tt=msqlStoreResult();
if (msqlNumRows($tt)<1) {
   $gname="Unknown Group";
   }
else {
   $gg=msqlFetchRow($tt);
   $gname=$gg[1];
   }
msqlFreeResult($tt);

if (msqlQuery($sock, "SELECT * FROM subgroup WHERE sgid=$sgroup")<0) {
   echo("<CENTER><TABLE WIDTH=400 BORDER=2 BGCOLOR=$color3>\n");
   echo("<TR><TD>\n<BR><CENTER>$ERRMSG</CENTER><BR>\n</TD></TR>\n</TABLE>\n");
   exit(0);
   }
$tt=msqlStoreResult();
if ((int)msqlNumRows($tt)<1) {
   $gname=$gname + " - Unknown SubGroup";
   }
else {
   $gg=msqlFetchRow($tt);
   $gname=$gname + " - " + $gg[2];
   }

msqlFreeResult($tt);

if ((char)$msg_type=="TEXT") {
   $msg_type=1;
   }
if ((char)$msg_type=="HTML") {
   $msg_type=2;
   }
if ((char)$msg_type=="HTML") {
   $msg_type=3;
   }


if (msqlQuery($sock, "SELECT _seq FROM message")<0) {
   echo("<CENTER><TABLE WIDTH=400 BORDER=2 BGCOLOR=$color3>\n");
   echo("<TR><TD>\n<BR><CENTER>$ERRMSG</CENTER><BR>\n</TD></TR>\n</TABLE>\n");
   exit(0);
   }
$tt=msqlStoreResult();
$nn=msqlFetchRow($tt);
msqlFreeResult($tt);
$new=(int)$nn[0];

$followup=0;

$remote_user=$ADDRESS_USER;

$insert="$group,$sgroup,$new,$followup,'$remote_user','$subj','$msg_type',$slicica,'$body'";

echo("$insert<BR>\n");

if (msqlQuery($sock, "INSERT INTO message VALUES($insert)")<0) {
   echo("<CENTER><TABLE WIDTH=400 BORDER=2 BGCOLOR=$color3>\n");
   echo("<TR><TD>\n<BR><CENTER>SNDMSG: $ERRMSG</CENTER><BR>\n</TD></TR>\n</TABLE>\n");
   exit(0);
   }
else {
   echo("Thank you, $remote_user.<BR>Your message has been received and stored to our database!<BR>\n");
   echo("Message received for: $gname<BR>\n");
   }


>
