<TITLE>Member administration</TITLE>
<BODY BGcolor=BLACK TEXT=WHITE ALINK=WHITE VLINK=WHITE LINK=WHITE>

<CENTER>
<FONT SIZE=5>Member Administration:</FONT><BR>
(add memeber)<BR>
<P></P>

<TABLE WIDTH=500>
<TR><TD><CENTER>
Please, select member and function you wold like to execute
</CENTER></TD></TR>
</TABLE>

<!
$color1="NAVY";
$color2="BLUE";
$color3="#99CCCC";
$color5="#2020FF";
$color4="RED";

$font1="WHITE";
$uname=$user;

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

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


if ($delete=="OK") {
   $imaga=0;
   if (msqlQuery($sock, "SELECT id_bill FROM billing WHERE id_us=$id_us")<0) {
      echo("<CENTER><TABLE WIDTH=400 BORDER=2 BGCOLOR=\"$color4\">\n");
      echo("<TR><TD>\n<BR><CENTER>$ERRMSG</CENTER><BR>\n</TD></TR>\n</TABLE>\n");
      exit(0);
      }
   $dt=msqlStoreResult();
   $id_bl=msqlFetchRow($dt);
   while(#$id_bl>0 && $imaga==0) {
      if (msqlQuery($sock, "SELECT id_trans FROM transaction WHERE id_bill=$id_bl[0]")<0) {
         echo("<CENTER><TABLE WIDTH=400 BORDER=2 BGCOLOR=\"$color4\">\n");
         echo("<TR><TD>\n<BR><CENTER>$ERRMSG</CENTER><BR>\n</TD></TR>\n</TABLE>\n");
         exit(0);
         }
      $dy=msqlStoreResult();
      $id_tr=msqlFetchRow($dy);
      if (#$id_tr>0) {
         $imaga=1;
         }
      msqlFreeResult($dy);
      $id_bl=msqlFetchRow($dt);
      }
   if ($imaga>0) {
      echo("<CENTER><TABLE WIDTH=400 BORDER=2 BGCOLOR=\"$color4\">\n");
      echo("<TR><TD>\n<BR><CENTER>Sorry, this user can not be DELETED.</CENTER><BR>\n</TD></TR>\n</TABLE>\n");
      exit(0);
      }
   if (msqlQuery($sock, "UPDATE user_data SET member='2' WHERE id_us=$id_us")<0) {
      echo("<CENTER><TABLE WIDTH=500 BORDER=2 BGCOLOR=\"$color4\">\n");
      echo("<TR><TD>\n<BR><CENTER>DELETE: $ERRMSG</CENTER><BR>\n</TD></TR>\n</TABLE>\n");
      exit(0);
      }

   }



if (msqlQuery($sock, "SELECT * FROM user_data WHERE member='1' AND user like '$uname'>0")<0) {
   echo("<CENTER><TABLE WIDTH=500 BORDER=2 BGCOLOR=\"$color4\">\n");
   echo("<TR><TD>\n<BR><CENTER>$ERRMSG</CENTER><BR>\n</TD></TR>\n</TABLE>\n");
   exit(0);
   }
$fd=msqlStoreResult();
$data=msqlFetchRow($fd);
$rows=msqlNumRows($fd);

if (#$data==0) {
   echo("<CENTER><TABLE WIDTH=400 BORDER=2 BGCOLOR=\"$color3\">\n");
   echo("<TR><TD>\n<BR><CENTER>Sorry, no members found.</CENTER><BR>\n</TD></TR>\n</TABLE>\n");
   exit(0);
   }

echo("<CENTER>\n<BR>\n<P>\n<TABLE WIDTH=500>\n");
	echo("<TR><TD WIDTH=20></td><TD WIDTH=100 BGCOLOR=\"$color1\"></td>");
	echo("<TD WIDTH=400 BGCOLOR=\"$color2\">\n<BR><CENTER>Members found: $rows</CENTER></TD></TR>\n");

while(#$data>0) {
   echo("<TR>\n");
   echo("<TD WIDTH=20><A HREF=\"listuser.msql?delete=OK&id_us=$data[0]\">del.</A></TD>\n");
   echo("<TD WIDTH=100 BGCOLOR=\"$color1\"><A HREF=\"userinfo.msql?id_us=$data[0]\"><CENTER>$data[1]</CENTER></A></TD>\n");
   echo("<TD WIDTH=300 BGCOLOR=\"$color2\"><FONT COLOR=\"$font1\">$data[4], $data[3]</FONT></TD>\n");
   echo("</TR>\n");
   $data=msqlFetchRow($fd);
   }

echo("</TABLE>\n");
echo("</FORM>\n");


msqlClose($sock);
>

