Posted on Saturday 16th August 2008 at 05:10 PM
I saw UrbanTwitch,tutorail, and I must say thank you soo much. However I found it a bit confusing to understand.I need help on making the tutorail work for me. I tried and to be honest it did not work. No bb codes got inserted into the text area when I clicked the buttons. Pleaase help this is my PMS.php
PHP Code
<?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 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 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 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' cellpadding='2' cellspacing='1' class='box'> <tr> <td height='18' colspan='2' align='left' class='row2' scope='col'>Message</td> </tr> <tr> <td height='18' colspan='2' align='left' class='row1' scope='col'>» Subject: $subject</td> </tr> <tr> <td height='19' colspan='2' align='left' class='row1' scope='row'>» From: $msg[from]</td> </tr> <tr> <td height='18' colspan='2' align='left' class='row3' scope='row'>» The Message: $message</td> </tr> <tr> <td width='64%' align='left' class='row1' scope='row'>» Your Reply</td> <td width='36%' align='left' class='row1' scope='row'><div align='right'><a href='?page=bbcode'>BB Code Help?</a></div></td> </tr> <tr> <td colspan='2' align='left' class='row1' scope='row'><center> <table width='100%' border='0' cellspacing='0' cellpadding='0'> <tr> <td width='22%' valign='bottom' scope='col'><div align='left'><font size='1'><FONT COLOR='green'> <A href='?page=bbcode'>BBcode</A> » Enabled </font></div></td> <td width='100%' scope='col'><center><textarea name="msg"2 cols="45" rows="6" class='input'></textarea></td> </tr> </table></td> </tr> <tr> <td colspan='2' align='left' class='row1' scope='row'><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'><FONT COLOR='green'> <A href='?page=bbcode'>BBcode</A> » Enabled </font></div></td> <td width='83%' class='row1' scope='col'><center> <textarea name="message" cols="45" rows="6" class='input'></textarea></td> </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 ?>