Posted on Sunday 7th September 2008 at 10:27 AM
I just saw Davas and Urbans pm system, and they are very good. I want help too. I am using RMB's PM system that has no save message system or sent message system. I really need them features as they are also a main part of an PM system. I also need help on PM status I get text like unread and read, witch sucks, I need images there. Please help me on that once thats done I want help on on more thing witch Ill introduce later. this is my code.
PHP Code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="https://www.w3.org/1999/xhtml"> <head> <script> function wrapText(el, openTag, closeTag) { if (el.setSelectionRange) { // W3C/Mozilla el.value = el.value.substring(0,el.selectionStart) + openTag + el.value.substring(el.selectionStart,el.selectionEnd) + closeTag + el.value.substring(el.selectionEnd,el.value.length); } else if (document.selection && document.selection.createRange) { // IE code goes here el.focus(); //or else text is added to the activating control var range = document.selection.createRange(); range.text = openTag + range.text + closeTag; } } </script> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php session_start(); //Start session if(!$logged[id]){ //Check if user is logged in header("Location: index.php?page=home&i=6"); }else{ //Their loggedin switch($_GET[act]){ //make some links ?page=case default: //set up the default page upon going to pms.php $msgs = mysql_query("SELECT * FROM `privates` WHERE `to` = '" . $logged[username] . "' ORDER BY `pid` ASC") or die(mysql_error()); //get all the messages to the loged in user echo "<div align='left'><font size='4'><strong>Private Messages</strong></font> </div> </div> <table width='99%' border='0' align='center' cellpadding='0' cellspacing='0'> <tr> <td height='5' scope='col'></td> </tr> </table> <table width='100%' border='0' align='center' cellpadding='1' cellspacing='1' class='box'> <tr> <td height='21' align='left' class='row1' scope='col'>Page Location » Private Messages » In Box</td> </tr> </table> <table width='99%' border='0' align='center' cellpadding='0' cellspacing='0'> <tr> <td height='5' scope='col'></td> </tr> </table> <table width='99%' border='0' align='center' cellpadding='0' cellspacing='0'> <tr> <td height='5' scope='col'></td> </tr> </table> <table width='100%' border='0' cellpadding='2' cellspacing='1' class='box'> <tr> <td height='18' align='left' class='row2' scope='col'>Options</td> </tr> <tr> <td height='20' align='left' class='row1' scope='col'><a href="?page=pms&act=compose">» Compose Message</a></td> </tr> <tr> <td height='20' align='left' class='row1' scope='col'><a href="?page=pms&act=delall"> » Delete All Messages</a></td> </tr> </table>"; //echo the start5 table and create msg link/delete all links! if(mysql_num_rows($msgs) == 0){ //check if there are messages or not echo "<table width='99%' border='0' align='center' cellpadding='0' cellspacing='0'> <tr> <td height='5' scope='col'></td> </tr> </table> <table width='100%' border='0' cellpadding='1' cellspacing='1' class='box'> <tr> <td height='18' colspan='5' align='left' class='row2' scope='col'>In Box</td> </tr> <tr> <td width='266' height='15' class='row3' scope='col'><div align='center'>Subject </div></td> <td width='266' class='row3' scope='col'><div align='center'>From</div></td> <td width='479' class='row3' scope='col'><div align='center'>Date</div></td> <td width='266' class='row3' scope='col'><div align='center'>Status</div></td> <th width='124' class='row3' scope='col'></th> </tr> <tr> <td height='18' colspan='5' align='left' class='row1' scope='col'>You Have No New Messages!</td> </tr> </table> <table width='100%' cellpadding='0' cellspacing='0'> <tr> <td align='center' valign='middle' width='100%'>"; //no new messages }else{ //or if there are messages echo "<table width='101%' border='0' align='center' cellpadding='0' cellspacing='0'> <tr> <td height='5' scope='col'></td> </tr> </table>"; echo "<table width='100%' border='0' cellpadding='3' cellspacing='1'> <tr> <td height='5' scope='col'></td> </tr> </table> <table width='100%' border='0' cellpadding='1' cellspacing='1' class='box'> <tr> <td height='18' colspan='5' align='left' class='row2' scope='col'>In Box</td> </tr> <tr> <td width='266' height='15' class='row3' scope='col'><div align='center'>Subject </div></td> <td width='266' class='row3' scope='col'><div align='center'>From</div></td> <td width='479' class='row3' scope='col'><div align='center'>Date</div></td> <td width='266' class='row3' scope='col'><div align='center'>Status</div></td> <th width='124' class='row3' scope='col'></th> </tr>"; while($r = mysql_fetch_array($msgs)){ //repeat for all the messages echo "<tr> <td align='center' class='row1' scope='col'><a href="?page=pms&act=view&id=$r[pid]">$r[subject]</a></td> <td align='center' class='row1' scope='col'><a href="members.php?user=$r[from]"><a href="members.php?user=$r[from]">$r[from]</a></td> <td align='center' class='row1' scope='col'>$r[date]</td> <td align='center' class='row1' scope='col'>$r[status]</td> <td align='center' class='row1' scope='col'><a href="?page=pms&act=delete&id=$r[pid]"><img src='images/Icons/delete.png'></a></td> </tr>"; //echo the messages } //end while } //end message amount check echo echo "</table>"; //end table error_reporting(E_ALL); $MyMessages = mysql_query("SELECT * FROM `privates` WHERE `to` = '$logged[username]' AND `status` = 'unread';"); //shows the user menu $MyMessages = mysql_num_rows($MyMessages); echo " <table width='100%' border='0' cellpadding='0' cellspacing='0'> <tr> <td height='10' align='left' scope='col'></td> </tr> </table> <table width='100%' border='0' cellpadding='0' cellspacing='0' class='box'> <tr> <td height='22' align='left' class='row1' scope='col'> You have $MyMessages new message.</td> </tr> </table> "; break; //end the default page case 'view': //define the view page $id = (int)htmlspecialchars(strip_tags($_GET[id])); //make the ID safe if(!$id){ //if there is no ID to select $bbmsg = BBCODE($message); header("Location: index.php?page=pms&i=19"); }else{ //or if there is.... $select = mysql_query("SELECT * FROM `privates` WHERE `pid` = '" . $id . "';"); //get the message's info $msg = mysql_fetch_array($select); //select all data if($msg[to] != $logged[username]){ //check if the user logged in is the owner of the message header("Location: index.php?page=pms&i=20"); }else{ //maybe... if(!$_POST[reply]) { //if the reply was not submitted $mark = mysql_query("UPDATE `privates` SET `status` = 'Read' WHERE `pid` = '" . $id . "'") or die(mysql_error()); //mark it as Read $message = nl2br(stripslashes($msg[content])); //make new lines to and strip the slashes $subject = stripslashes($msg[subject]); //strip the slashes $date = date("F j, Y, g:i a"); //the date sent echo"<div align='left'><font size='4'><strong>Private Messages</strong></font> </div> <table width='99%' border='0' align='center' cellpadding='0' cellspacing='0'> <tr> <td height='5' scope='col'></td> </tr> </table> <table width='100%' border='0' align='center' cellpadding='1' cellspacing='1' class='box'> <tr> <td height='21' align='left' class='row1' scope='col'>Page Location » Private Messages » Viewing Messages</td> </tr> </table> <table width='99%' border='0' align='center' cellpadding='0' cellspacing='0'> <tr> <td height='5' scope='col'></td> </tr> </table> <table width='99%' border='0' align='center' cellpadding='0' cellspacing='0'> <tr> <td height='5' scope='col'></td> </tr> </table> <table width='100%' border='0' align='center' cellpadding='0' cellspacing='0'> <tr> <td height='5' scope='col'> <form method="post"> <table width='100%' border='0' align='center' cellpadding='1' cellspacing='1' class='box'> <tr> <td height='18' colspan='3' align='left' class='row2' scope='col'> <IMG height='6' src='images/bullet.gif' width='4'> <span class='forum_text'>$subject</span></td> </tr> <tr> <td width='24%' height='12' align='left' class='row3' scope='col'>$msg[from]</td> <td colspan='2' align='left' class='row3' scope='col'><div align='right'>$date </div></td> </tr> <tr> <td height='16' align='left' class='row1' scope='col'>";{ if ($user[userlevel] == 6) { echo ("<img src="images/titles/icon4.bmp">"); } elseif ($user[userlevel] == 4) { echo ("<img src="images/titles/icon1.bmp">"); } else { echo ("<img src="images/titles/icon5.bmp">"); } } echo "</td> <td width='65%' align='left' class='row1' scope='col'> $message</td> <td width='11%' align='left' class='row1' scope='col'></td> </tr> <tr> <td height='10' align='left' class='row1' scope='col'></td> <td align='left' class='row1' scope='col'></td> <td align='left' class='row1' scope='col'></td> </tr> </table> <table width='99%' border='0' align='center' cellpadding='0' cellspacing='0'> <tr> <td height='5' scope='col'></td> </tr> </table> <table width='100%' border='0' cellpadding='1' cellspacing='1' class='box'> <tr> <td height='18' colspan='3' align='left' class='row2' scope='col'>Add Reply</td> </tr> <tr> <td colspan='3' align='right' class='row3' scope='col'><a href='?page=bbcode'>BB Code Help?</a></td> </tr> <tr> <td width='23%' align='left' valign='bottom' class='row1' scope='col'><div align='left'><font size='1'> <div align='center'>$emotion</div> </div> <div align='left'><font size='1'> BBcode<FONT COLOR='green'> » Enabled </font></div> <div align='left'><font size='1'> Smileys<FONT COLOR='green'> » Enabled </font></div></td> <td width='77%' colspan='2' align='left' class='row1' scope='col'><center>$tags</center> <center> <textarea id="TheTextArea" name="msg"2 cols="45" rows="6" class='input'></textarea></td> </tr> <tr> <td colspan='3' align='left' class='row1' scope='col'><input name="reply" type="submit" class='boxbutton' value="Reply"></td> </tr> </table> <table width='99%' border='0' align='center' cellpadding='0' cellspacing='0'> <tr> <td height='5' scope='col'></td> </tr> </table> <table width='100%' border='0' align='center' cellpadding='1' cellspacing='1' class='box'> <tr> <td height='21' align='left' class='row1' scope='col'><a href='index.php?page=pms'>Go Back?</a></td> </tr> </table> </form ></td> </tr> </table>"; //echo the message and reply box. }else{ //if the form was submitted $to = $msg[from]; //get who it is to $from = $logged[username]; //who its from $subject = "RE: " . $msg[subject]; //new subject $msg = addslashes($_POST[msg]); //the content $date = date("F j, Y, g:i a"); //the date sent $do = mysql_query("INSERT INTO `privates` (`to`,`from`,`date`,`subject`,`content`) VALUES ('" . $to . "','" . $from . "','" . $date . "','" . $subject . "','" . $msg . "')") or die(mysql_error()); //insert into the table! header("Location: index.php?page=pms&i=21"); } //end reply check } //end check posession } //end id check break; case 'compose': //create a new message echo "<div align='left'><font size='4'><strong>Private Messages</strong></font> </div> <table width='99%' border='0' align='center' cellpadding='0' cellspacing='0'> <tr> <td height='5' scope='col'></td> </tr> </table> <table width='100%' border='0' align='center' cellpadding='1' cellspacing='1' class='box'> <tr> <td height='21' align='left' class='row1' scope='col'>Page Location » Private Messages » Compose Message</td> </tr> </table> <table width='99%' border='0' align='center' cellpadding='0' cellspacing='0'> <tr> <td height='5' scope='col'></td> </tr> </table> <table width='99%' border='0' align='center' cellpadding='0' cellspacing='0'> <tr> <td height='5' scope='col'></td> </tr> </table>"; echo " <table width='100%' border='0' align='center' cellpadding='1' cellspacing='1' class='box'>"; if(!$_POST[send]){ //if the form was not submitted echo "<form method="post" action=""> <tr> <td height='20' colspan='2' align='left' class='row2' scope='row'>Compose Message.</td> </tr>"; //echo some of the form and whatnot if(isset($_GET[user])){ //check if there is a user in the address bar echo "<tr> <td colspan='2' align='left' class='row1' scope='row'>» To User <input class='input' type="text" name="to" value="$_GET[user]" size="15"> <span class='imp'>* Provided </span></td> </tr>"; }else{ //or not.. echo "<tr> <td colspan='2' align='left' class='row1' scope='row'>» To User <input class='input' type="text" name="to" size="15"> <span class='imp'>* Required </span></td> </tr>"; //echo the input box without the value of the user! } //end user check in address bar echo "<form> <tr> <td width='17%' align='left' class='row1' scope='col'>» Subject:</td> <td width='83%' align='left' class='row1' scope='col'> <input name="title" type="text" class='input' value="Unitiled Message" size="15" Message> </td> </tr> <tr> <td width='22%' align='left' class='row1' scope='row'>» Content</td> <td width='83%' align='left' class='row1' scope='row'><div align='right'><a href='?page=bbcode'>BB Code Help?</a></div></td> </tr> <tr> <td width='17%' valign='bottom' class='row1' scope='col'><div align='left'><font size='1'> <div align='center'>$emotion</div> </div> <div align='left'><font size='1'><FONT COLOR='green'><A href='?page=bbcode'>BBcode</A> » Enabled </font></div> <div align='left'><font size='1'><FONT COLOR='green'><A href='?page=bbcode'>Smileys</A> » Enabled </font></div></td> <td width='83%' class='row1' scope='col'><center> $tags <textarea id="TheTextArea" name="message" cols="45" rows="6" class='input'></textarea> <br><div style='padding-left: 5px; padding-top:5px;'> </tr> <tr> <td colspan='2' align='left' class='row1' scope='row'><input name="send" type="submit" class='boxbutton' value="Send Message"> </td> </tr> </form>"; //echo the rest of the form echo "<table width='99%' border='0' align='center' cellpadding='0' cellspacing='0'> <tr> <td height='5' scope='col'></td> </tr>"; echo "<table width='100%' border='0' align='center' cellpadding='1' cellspacing='1' class='box'> <tr> <td height='21' align='left' class='row1' scope='col'><a href='index.php?page=pms'>Go Back?</a></td> </tr>"; echo "</table>"; }else{ //or if it was.. echo "</table>"; echo "</table>"; echo "</table>"; $to = stripslashes(htmlspecialchars(strip_tags($_POST[to]))); //who its to $from = $logged[username]; //who its from $date = date("F j, Y, g:i a"); //the date sent $msg = addslashes($_POST[message]); //the message variable $subject = addslashes($_POST[title]); //the subject $do = mysql_query("INSERT INTO `privates` (`to`,`from`,`date`,`subject`,`content`) VALUES ('" . $to . "','" . $from . "','" . $date . "','" . $subject . "','" . $msg . "')") or die(mysql_error()); //insert into the table! header("Location: index.php?page=pms&i=21"); } //end sent check break; //end make new msg case 'delall': //delete all page $get = mysql_query("SELECT * FROM `privates` WHERE `to` = '" . $logged[username] . "'"); //get the private messages if(mysql_num_rows($get) == "0"){ header("Location: index.php?page=pms&i=23"); }else{ $delete = mysql_query("DELETE FROM `privates` WHERE `to` = '" . $logged[username] . "'"); //delete tehm if($delete) { //check if theres a mySQL error header("Location: index.php?page=pms&i=22"); //success }else{ //or not header("Location: index.php?page=pms&i=24"); } //end error check } //end msg check break; //end page case 'delete': //start the delete page! $id = (int)htmlspecialchars(strip_tags($_GET[id])); //make the ID safe if(!$id){ //if there is no ID to select echo "<a href="?page=pms">Go Back</a>No ID Selected!"; //echo the error }else{ //or if there is.... $select = mysql_query("SELECT * FROM `privates` WHERE `pid` = '" . $id . "'"); //get the message's info $msg = mysql_fetch_array($select); //select all data if($msg[to] != $logged[username]){ //check if the user logged in is the owner of the message header("Location: index.php?page=pms&i=20"); //if not }else{ //maybe... $do = mysql_query("DELETE FROM `privates` WHERE `pid` = '" . $id . "'") or die(mysql_error()); header("Location: index.php?page=pms&i=25"); } //end check possession } //end id check break; //end the delete page! } //end switch/get } //end login check ?> </body> </html>