eaglelegend Posted May 2, 2008 Share Posted May 2, 2008 Hey, I am unsure what's up with my system exactly, but here are the problems! Status doesn't change from "Unread" to "Read". Reply don't reply, it just go "mail.php?action=sendmsg" Other stuff I would like to add is: Delete don't delete message completely, but just into another table, where staff ect. can see it. Report, user clicks report and the messages viewable by staff, reported messages will "float" to the top and change colour where staff can be alerted about bad messages quickly and properly. I wont be able to work out how to do any of the above, but all help, with the errors as well will be gratefully accepted, and thank you in advance! <?php include("header.php"); include("members.php"); $a = $_GET['action']; $u = $_COOKIE['ELv2']; ?> <h2>Message Center</h2> <input type='button' value='Send a New Message!' onClick='parent.location="/mail.php?action=newmsg"' class='text_box' style='width: 200px' alt='Send a message!' title='Send a message!'> <input type='button' value='Inbox!' onClick='parent.location="/mail.php?action=inbox"' class='text_box' style='width: 200px' alt='View your recieved mail!' title='View your recieved mail!'> <?php if($a == 'inbox') { print "<br><h1>Inbox</h1><p> <table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" width=\"100%\" bgcolor=\"#000000\"> <tr> <Td bgcolor=\"#dddddd\" class=\"text_box\">Subject</td> <td bgcolor=\"#dddddd\" class=\"text_box\">From</td> <td bgcolor=\"#dddddd\" class=\"text_box\">Date</td> <td bgcolor=\"#dddddd\" class=\"text_box\">Status</td> <td bgcolor=\"#dddddd\" class=\"text_box\">Actions</td> </tr>"; $query = "SELECT * FROM `messages` WHERE `to` = '{$_COOKIE['ELv2']}' AND `site` = '$Z' ORDER BY `id` DESC"; $sql = mysql_query($query) or die("MySQL Error in query: ".$query."<br />".mysql_error()); while($row = mysql_fetch_array($sql)) { extract($row); print "<tr> <td bgcolor=\"#ffffff\" class=\"other\">" . $subject . "</td> <td bgcolor=\"#ffffff\" class=\"other\">" . $from . "</td> <td bgcolor=\"#ffffff\" class=\"other\">" . $date . "</td> <td bgcolor=\"#ffffff\" class=\"other\">" . $status . "</td> <td bgcolor=\"#ffffff\" class=\"other\"><a href=\"mail.php?action=view&id=" . $id . "\">Read - <a href=\"mail.php?action=delete&id=" . $id . "\">Delete</td> </tr>"; } print "</table>"; } else { // add if statement to prevent showing on wrong page. if($a != 'view' && $a != 'delete' && $a != 'sview'){ echo "<h1>Send Message</h1><p> <form action=\"mail.php?action=sendmsg\" method=\"post\">"; echo "<input type=\"radio\" name=\"type\" value=\"1\" class=\"text_box\" alt=\"Click here if you are sending your message outside this site via email\" title=\"Click here if you are sending your message outside this site via email\"> Email <input type=\"radio\" name=\"type\" value=\"2\" checked class=\"text_box\" alt=\"Click here if you are sending a message within this site and NOT via email!\" title=\"Click here if you are sending a message within this site and NOT via email!\"> Private Message <br> To: <br> <input type=\"text\" name=\"to\" class=\"text_box\" alt=\"Who do you want to send your message to?\" title=\"Who do you want to send your message to?\"><p> From:<br> <select name=\"from\" size=\"1\" class=\"text_box\" alt=\"Please choose where your sending from!\" title=\"Please choose where you are sending from!\">"; $sql = mysql_query("SELECT * FROM `members` WHERE `username`='{$_COOKIE['ELv2']}'"); while($row = mysql_fetch_array($sql)) { $us = $row["username"]; print "<option value=\"" . $us . "\">" . $us . "</option> <option value=\"" . $us . "@eaglelegend.com\">" . $us . "@eaglelegend.com</option>"; } print "</select><p> Subject:<br> <input type=\"text\" name=\"subject\" size=\"30\" class=\"text_box\" alt=\"What is the title/subject of your message?\" title=\"What is the title/subject of your message?\"><p> Message:<br> <textarea rows=\"6\" cols=\"60\" nowrap name=\"message\" class=\"text_box\" alt=\"Please enter your message!\" title=\"Please enter your message!\"></textarea><p> <input type=\"submit\" value=\" Send Message \" class=\"text_box\" alt=\"Click here to send your message!\" title=\"Click here to send your message!\"></form>"; } $query = "SELECT `email` FROM `members` WHERE `username`='".mysql_escape_string($username)."' LIMIT 1"; if($a == 'sendmsg' && $_POST['type'] == 1){ $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/plain; charset=iso-8859-1\r\n"; $headers .= "To: ".trim($_POST['to'])."\r\n"; $headers .= "From: ".trim($_POST['from'])."\r\n"; $headers .= "Reply-To: ".trim($email)."\r\nnew;reply-to: ".trim($email)."\r\n"; @mail(trim($_POST['to']), trim($_POST['subject']), $_POST['message'], $headers); echo("Mail sent to ".trim($_POST['to']) ); } if($a == 'sendmsg' && $_POST['type'] == 2) { $subject = $_POST['subject']; $message = $_POST['message']; $date = date("m/d/y"); $status = "unread"; $to = $_POST['to']; if($subject && $to && $message) { $insert = mysql_query("INSERT INTO `messages` (`site`, `subject`, `body`, `status`, `date`, `to`, `from`) VALUES($Z, $subject, $message, $status, $date, $to, '{$_COOKIE['ELv2']}')"); $insert = mysql_query("INSERT INTO `messages` (`site`, `subject`, `body`, `status`, `date`, `to`, `from`) VALUES('$Z', '$subject', '$message', '$status', '$date', '$to', '{$_COOKIE['ELv2']}')"); if($insert) { print "<h2>Message Sent</h2><p> Your message has been sent!<P> <a href=\"mail.php?action=inbox\">Back to Inbox"; } else { print mysql_error(); } } else { print "Subject, To User, and Message are required!"; } } if($a == 'delete') { $id = $_GET['id']; $del = mysql_query("DELETE FROM `messages` WHERE `id` = '$id' AND `site` = '$Z'"); if($del) { Header("Location: mail.php?action=inbox"); } else { print mysql_error(); } } //Below is to view inbox mail if($a !== 'view') { $id = $_GET['id']; $us = $_COOKIE['ELv2']; $update = mysql_query("UPDATE `messages` SET `status`='read' WHERE `id`='$id' AND `site`=$Z"); $query = "SELECT * FROM `messages` WHERE `id`='$id' AND `site` = '$Z'"; $sql = mysql_query($query) or die("MySQL Error in query: ".$query."<br />".mysql_error()); while($row = mysql_fetch_array($sql)) { extract($row); print "<h2>" . $subject . "</h2><p> To: " . $to . "<br> From: " . $from . "<br> Date: " . $date . "<p> <form action=\"mail.php?action=sendmsg\" method=\"post\"> <input type=\"hidden\" name=\"to\" value=\"" . $from . "\" class=\"text_box\"> <input type=\"hidden\" name=\"subject\" value=\"RE: " . $subject . "\" class=\"text_box\"> Message:<br> <textarea rows=\"6\" cols=\"60\" nowrap name=\"message\" class=\"text_box\"> $body </textarea><p>"; } } } include("footer.php"); ?> Quote Link to comment Share on other sites More sharing options...
MadTechie Posted May 2, 2008 Share Posted May 2, 2008 codes a mess site=$Z ? whats $Z? its not set anyway.. the status should work if you change if($a !== 'view') { to if($a == 'view') { reply <form action=\"mail.php?action=sendmsg\" method=\"post\"> <!--add the line below--> <input type=\"hidden\" name=\"type\" value=\"1\"><!--could be 2--> <input type=\"hidden\" name=\"to\" value=\"" . $from . "\" class=\"text_box\"> *delete looks fine (after a quick scan) I wont be able to work out how to do any of the above, so wheres the author ? Quote Link to comment Share on other sites More sharing options...
eaglelegend Posted May 2, 2008 Author Share Posted May 2, 2008 The author charged me $50 for it, and it was so messed up >_< I did my best, will little help here and there to fix it up. the original author NEVER helped me :/ im sorry. Also, how can I have it "alert" that someone has new mail? thanks btw! Quote Link to comment Share on other sites More sharing options...
MadTechie Posted May 2, 2008 Share Posted May 2, 2008 without really checking the whole thing its hard give you, good advice their are security holes in the system (even in the code below) but without more detail i see what i can do.. this may work <?php $query = "SELECT count(*) as msgs FROM `messages` WHERE `to` = '{$_COOKIE['ELv2']}' AND `site` = '$Z' "; $sql = mysql_query($query) or die("MySQL Error in query: ".$query."<br />".mysql_error()); $msg = mysql_fetch_array($sql)); echo "You have {$msg['msgs']} messages"; //changed 'msgs ' to 'msgs' //code below exists already add the above code above it if($a == 'inbox') { print "<br><h1>Inbox</h1><p> ?> EDIT: oops typeo ( Quote Link to comment Share on other sites More sharing options...
eaglelegend Posted May 2, 2008 Author Share Posted May 2, 2008 Parse error: syntax error, unexpected ')' in /misc/39/000/171/334/2/user/web/eaglelegend.com/mail.php on line 22 and sorry, where do I put a ) you were saying about? Quote Link to comment Share on other sites More sharing options...
MadTechie Posted May 2, 2008 Share Posted May 2, 2008 can you post the code you now have.. Quote Link to comment Share on other sites More sharing options...
eaglelegend Posted May 2, 2008 Author Share Posted May 2, 2008 <?php include("header.php"); include("members.php"); $a = $_GET['action']; $u = $_COOKIE['ELv2']; ?> <h2>Message Center</h2> <input type='button' value='Send a New Message!' onClick='parent.location="/mail.php?action=newmsg"' class='text_box' style='width: 200px' alt='Send a message!' title='Send a message!'> <input type='button' value='Inbox!' onClick='parent.location="/mail.php?action=inbox"' class='text_box' style='width: 200px' alt='View your recieved mail!' title='View your recieved mail!'> <input type='button' value='Outbox!' onClick='parent.location="/mail.php?action=outbox"' class='text_box' style='width: 200px' alt='View mail you have sent!' title='View mail you have sent!'> <?php $query = "SELECT count(*) as msgs FROM `messages` WHERE `to` = '{$_COOKIE['ELv2']}' AND `site` = '$Z' "; $sql = mysql_query($query) or die("MySQL Error in query: ".$query."<br />".mysql_error()); $msg = mysql_fetch_array($sql)); echo "You have {$msg['msgs']} messages"; //changed 'msgs ' to 'msgs' if($a == 'inbox') { print "<br><h1>Inbox</h1><p> <table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" width=\"100%\" bgcolor=\"#000000\"> <tr> <Td bgcolor=\"#dddddd\" class=\"text_box\">Subject</td> <td bgcolor=\"#dddddd\" class=\"text_box\">From</td> <td bgcolor=\"#dddddd\" class=\"text_box\">Date</td> <td bgcolor=\"#dddddd\" class=\"text_box\">Status</td> <td bgcolor=\"#dddddd\" class=\"text_box\">Actions</td> </tr>"; $query = "SELECT * FROM `messages` WHERE `to` = '{$_COOKIE['ELv2']}' AND `site` = '$Z' ORDER BY `id` DESC"; $sql = mysql_query($query) or die("MySQL Error in query: ".$query."<br />".mysql_error()); while($row = mysql_fetch_array($sql)) { extract($row); print "<tr> <td bgcolor=\"#ffffff\" class=\"other\">" . $subject . "</td> <td bgcolor=\"#ffffff\" class=\"other\">" . $from . "</td> <td bgcolor=\"#ffffff\" class=\"other\">" . $date . "</td> <td bgcolor=\"#ffffff\" class=\"other\">" . $status . "</td> <td bgcolor=\"#ffffff\" class=\"other\"><a href=\"mail.php?action=view&id=" . $id . "\">Read - <a href=\"mail.php?action=delete&id=" . $id . "\">Delete</td> </tr>"; } print "</table>"; } elseif ($a == 'outbox') { print "<br><h1>Outbox</h2><p> <table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" width=\"100%\" bgcolor=\"#000000\"> <tr> <Td bgcolor=\"#dddddd\" class=\"text_box\">Subject</td> <td bgcolor=\"#dddddd\" class=\"text_box\">To</td> <td bgcolor=\"#dddddd\" class=\"text_box\">Date</td> <td bgcolor=\"#dddddd\" class=\"text_box\">Status</td> <td bgcolor=\"#dddddd\" class=\"text_box\">Actions</td> </tr>"; $query = "SELECT * FROM `messages` WHERE `from` = '{$_COOKIE['ELv2']}' AND `site` = '$Z' ORDER BY `id` DESC"; $sql = mysql_query($query) or die("MySQL Error in query: ".$query."<br />".mysql_error()); while($row = mysql_fetch_array($sql)) { extract($row); print "<tr> <td bgcolor=\"#ffffff\" class=\"other\">" . $subject . "</td> <td bgcolor=\"#ffffff\" class=\"other\">" . $to . "</td> <td bgcolor=\"#ffffff\" class=\"other\">" . $date . "</td> <td bgcolor=\"#ffffff\" class=\"other\">" . $status . "</td> <td bgcolor=\"#ffffff\" class=\"other\"><a href=\"mail.php?action=sview&id=" . $id . "\">Read - <a href=\"mail.php?action=delete&id=" . $id . "\">Delete</td> </tr>"; } print "</table>"; } else { // add if statement to prevent showing on wrong page. if($a != 'view' && $a != 'delete' && $a != 'sview'){ echo "<h1>Send Message</h1><p> <form action=\"mail.php?action=sendmsg\" method=\"post\">"; echo "<input type=\"radio\" name=\"type\" value=\"1\" class=\"text_box\" alt=\"Click here if you are sending your message outside this site via email\" title=\"Click here if you are sending your message outside this site via email\"> Email <input type=\"radio\" name=\"type\" value=\"2\" checked class=\"text_box\" alt=\"Click here if you are sending a message within this site and NOT via email!\" title=\"Click here if you are sending a message within this site and NOT via email!\"> Private Message <br> To: <br> <input type=\"text\" name=\"to\" class=\"text_box\" alt=\"Who do you want to send your message to?\" title=\"Who do you want to send your message to?\"><p> From:<br> <select name=\"from\" size=\"1\" class=\"text_box\" alt=\"Please choose where your sending from!\" title=\"Please choose where you are sending from!\">"; $sql = mysql_query("SELECT * FROM `members` WHERE `username`='{$_COOKIE['ELv2']}'"); while($row = mysql_fetch_array($sql)) { $us = $row["username"]; print "<option value=\"" . $us . "\">" . $us . "</option> <option value=\"" . $us . "@eaglelegend.com\">" . $us . "@eaglelegend.com</option>"; } print "</select><p> Subject:<br> <input type=\"text\" name=\"subject\" size=\"30\" class=\"text_box\" alt=\"What is the title/subject of your message?\" title=\"What is the title/subject of your message?\"><p> Message:<br> <textarea rows=\"6\" cols=\"60\" nowrap name=\"message\" class=\"text_box\" alt=\"Please enter your message!\" title=\"Please enter your message!\"></textarea><p> <input type=\"submit\" value=\" Send Message \" class=\"text_box\" alt=\"Click here to send your message!\" title=\"Click here to send your message!\"></form>"; } $query = "SELECT `email` FROM `members` WHERE `username`='".mysql_escape_string($username)."' LIMIT 1"; if($a == 'sendmsg' && $_POST['type'] == 1){ $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/plain; charset=iso-8859-1\r\n"; $headers .= "To: ".trim($_POST['to'])."\r\n"; $headers .= "From: ".trim($_POST['from'])."\r\n"; $headers .= "Reply-To: ".trim($email)."\r\nnew;reply-to: ".trim($email)."\r\n"; @mail(trim($_POST['to']), trim($_POST['subject']), $_POST['message'], $headers); echo("Mail sent to ".trim($_POST['to']) ); } if($a == 'sendmsg' && $_POST['type'] == 2) { $subject = $_POST['subject']; $message = $_POST['message']; $date = date("m/d/y"); $status = "unread"; $to = $_POST['to']; if($subject && $to && $message) { $insert = mysql_query("INSERT INTO `messages` (`site`, `subject`, `body`, `status`, `date`, `to`, `from`) VALUES($Z, $subject, $message, $status, $date, $to, '{$_COOKIE['ELv2']}')"); $insert = mysql_query("INSERT INTO `messages` (`site`, `subject`, `body`, `status`, `date`, `to`, `from`) VALUES('$Z', '$subject', '$message', '$status', '$date', '$to', '{$_COOKIE['ELv2']}')"); if($insert) { print "<h2>Message Sent</h2><p> Your message has been sent!<P> <a href=\"mail.php?action=inbox\">Back to Inbox"; } else { print mysql_error(); } } else { print "Subject, To User, and Message are required!"; } } // OMG I can read!... below is to view outward images!... DUH! if($a !== 'sview') { $id = $_GET['id']; $us = $_COOKIE['ELv2']; $update = mysql_query("UPDATE `messages` SET status = 'read' WHERE `id`='$id' AND `site`= $Z"); $query = "SELECT * FROM `messages` WHERE `id`='$id' AND `site` = '$Z'"; $sql = mysql_query($query) or die("MySQL Error in query: ".$query."<br />".mysql_error()); while($row = mysql_fetch_array($sql)) { extract($row); print "<h2>" . $subject . "</h2><p> To: " . $to . " <br>From: " . $from . " <br>Date: " . $date . "<p> " . $body . "<p> <form action=\"mail.php?action=sendmsg\" method=\"post\"> <input type=\"hidden\" name=\"to\" value=\"" . $from . "\" class=\"text_box\"> <input type=\"hidden\" name=\"subject\" value=\"RE: " . $subject . "\" class=\"text_box\"> Reply:<br> <textarea rows=\"6\" cols=\"60\" nowrap name=\"message\" class=\"text_box\"> <p><p>Original Message --------------------------- To: " . $to . " From: " . $from . " Date: " . $date . " Message: " . $body . "</textarea><p> <input type=\"submit\" value=\" Send Reply \" class=\"text_box\"></form>"; } } /* EXTERMINATE!... Delete messages below HOWEVER, I wish to have it not delete completely from the server, ie. the staff can only see it!*/ if($a == 'delete') { $id = $_GET['id']; $del = mysql_query("DELETE FROM `messages` WHERE `id` = '$id' AND `site` = '$Z'"); if($del) { Header("Location: mail.php?action=inbox"); } else { print mysql_error(); } } //Below is to view inbox mail if($a !== 'view') { $id = $_GET['id']; $us = $_COOKIE['ELv2']; $update = mysql_query("UPDATE `messages` SET `status`='read' WHERE `id`='$id' AND `site`=$Z"); $query = "SELECT * FROM `messages` WHERE `id`='$id' AND `site` = '$Z'"; $sql = mysql_query($query) or die("MySQL Error in query: ".$query."<br />".mysql_error()); while($row = mysql_fetch_array($sql)) { extract($row); print "<h2>" . $subject . "</h2><p> To: " . $to . "<br> From: " . $from . "<br> Date: " . $date . "<p> <form action=\"mail.php?action=sendmsg\" method=\"post\"> <input type=\"hidden\" name=\"to\" value=\"" . $from . "\" class=\"text_box\"> <input type=\"hidden\" name=\"subject\" value=\"RE: " . $subject . "\" class=\"text_box\"> Message:<br> <textarea rows=\"6\" cols=\"60\" nowrap name=\"message\" class=\"text_box\"> $body </textarea><p>"; } } } include("footer.php"); ?> Quote Link to comment Share on other sites More sharing options...
MadTechie Posted May 2, 2008 Share Posted May 2, 2008 updated <?php include("header.php"); include("members.php"); $a = $_GET['action']; $u = $_COOKIE['ELv2']; ?> <h2>Message Center</h2> <input type='button' value='Send a New Message!' onClick='parent.location="/mail.php?action=newmsg"' class='text_box' style='width: 200px' alt='Send a message!' title='Send a message!'> <input type='button' value='Inbox!' onClick='parent.location="/mail.php?action=inbox"' class='text_box' style='width: 200px' alt='View your recieved mail!' title='View your recieved mail!'> <input type='button' value='Outbox!' onClick='parent.location="/mail.php?action=outbox"' class='text_box' style='width: 200px' alt='View mail you have sent!' title='View mail you have sent!'> <?php $query = "SELECT count(*) as msgs FROM `messages` WHERE `to` = '{$_COOKIE['ELv2']}' AND `site` = '$Z' "; $sql = mysql_query($query) or die("MySQL Error in query: ".$query."<br />".mysql_error()); $msg = mysql_fetch_array($sql); echo "You have {$msg['msgs']} messages"; if($a == 'inbox') { print "<br><h1>Inbox</h1><p> <table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" width=\"100%\" bgcolor=\"#000000\"> <tr> <Td bgcolor=\"#dddddd\" class=\"text_box\">Subject</td> <td bgcolor=\"#dddddd\" class=\"text_box\">From</td> <td bgcolor=\"#dddddd\" class=\"text_box\">Date</td> <td bgcolor=\"#dddddd\" class=\"text_box\">Status</td> <td bgcolor=\"#dddddd\" class=\"text_box\">Actions</td> </tr>"; $query = "SELECT * FROM `messages` WHERE `to` = '{$_COOKIE['ELv2']}' AND `site` = '$Z' ORDER BY `id` DESC"; $sql = mysql_query($query) or die("MySQL Error in query: ".$query."<br />".mysql_error()); while($row = mysql_fetch_array($sql)) { extract($row); print "<tr> <td bgcolor=\"#ffffff\" class=\"other\">" . $subject . "</td> <td bgcolor=\"#ffffff\" class=\"other\">" . $from . "</td> <td bgcolor=\"#ffffff\" class=\"other\">" . $date . "</td> <td bgcolor=\"#ffffff\" class=\"other\">" . $status . "</td> <td bgcolor=\"#ffffff\" class=\"other\"><a href=\"mail.php?action=view&id=" . $id . "\">Read - <a href=\"mail.php?action=delete&id=" . $id . "\">Delete</td> </tr>"; } print "</table>"; } elseif ($a == 'outbox') { print "<br><h1>Outbox</h2><p> <table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" width=\"100%\" bgcolor=\"#000000\"> <tr> <Td bgcolor=\"#dddddd\" class=\"text_box\">Subject</td> <td bgcolor=\"#dddddd\" class=\"text_box\">To</td> <td bgcolor=\"#dddddd\" class=\"text_box\">Date</td> <td bgcolor=\"#dddddd\" class=\"text_box\">Status</td> <td bgcolor=\"#dddddd\" class=\"text_box\">Actions</td> </tr>"; $query = "SELECT * FROM `messages` WHERE `from` = '{$_COOKIE['ELv2']}' AND `site` = '$Z' ORDER BY `id` DESC"; $sql = mysql_query($query) or die("MySQL Error in query: ".$query."<br />".mysql_error()); while($row = mysql_fetch_array($sql)) { extract($row); print "<tr> <td bgcolor=\"#ffffff\" class=\"other\">" . $subject . "</td> <td bgcolor=\"#ffffff\" class=\"other\">" . $to . "</td> <td bgcolor=\"#ffffff\" class=\"other\">" . $date . "</td> <td bgcolor=\"#ffffff\" class=\"other\">" . $status . "</td> <td bgcolor=\"#ffffff\" class=\"other\"><a href=\"mail.php?action=sview&id=" . $id . "\">Read - <a href=\"mail.php?action=delete&id=" . $id . "\">Delete</td> </tr>"; } print "</table>"; } else { // add if statement to prevent showing on wrong page. if($a != 'view' && $a != 'delete' && $a != 'sview'){ echo "<h1>Send Message</h1><p> <form action=\"mail.php?action=sendmsg\" method=\"post\">"; echo "<input type=\"radio\" name=\"type\" value=\"1\" class=\"text_box\" alt=\"Click here if you are sending your message outside this site via email\" title=\"Click here if you are sending your message outside this site via email\"> Email <input type=\"radio\" name=\"type\" value=\"2\" checked class=\"text_box\" alt=\"Click here if you are sending a message within this site and NOT via email!\" title=\"Click here if you are sending a message within this site and NOT via email!\"> Private Message <br> To: <br> <input type=\"text\" name=\"to\" class=\"text_box\" alt=\"Who do you want to send your message to?\" title=\"Who do you want to send your message to?\"><p> From:<br> <select name=\"from\" size=\"1\" class=\"text_box\" alt=\"Please choose where your sending from!\" title=\"Please choose where you are sending from!\">"; $sql = mysql_query("SELECT * FROM `members` WHERE `username`='{$_COOKIE['ELv2']}'"); while($row = mysql_fetch_array($sql)) { $us = $row["username"]; print "<option value=\"" . $us . "\">" . $us . "</option> <option value=\"" . $us . "@eaglelegend.com\">" . $us . "@eaglelegend.com</option>"; } print "</select><p> Subject:<br> <input type=\"text\" name=\"subject\" size=\"30\" class=\"text_box\" alt=\"What is the title/subject of your message?\" title=\"What is the title/subject of your message?\"><p> Message:<br> <textarea rows=\"6\" cols=\"60\" nowrap name=\"message\" class=\"text_box\" alt=\"Please enter your message!\" title=\"Please enter your message!\"></textarea><p> <input type=\"submit\" value=\" Send Message \" class=\"text_box\" alt=\"Click here to send your message!\" title=\"Click here to send your message!\"></form>"; } $query = "SELECT `email` FROM `members` WHERE `username`='".mysql_escape_string($username)."' LIMIT 1"; if($a == 'sendmsg' && $_POST['type'] == 1){ $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/plain; charset=iso-8859-1\r\n"; $headers .= "To: ".trim($_POST['to'])."\r\n"; $headers .= "From: ".trim($_POST['from'])."\r\n"; $headers .= "Reply-To: ".trim($email)."\r\nnew;reply-to: ".trim($email)."\r\n"; @mail(trim($_POST['to']), trim($_POST['subject']), $_POST['message'], $headers); echo("Mail sent to ".trim($_POST['to']) ); } if($a == 'sendmsg' && $_POST['type'] == 2) { $subject = $_POST['subject']; $message = $_POST['message']; $date = date("m/d/y"); $status = "unread"; $to = $_POST['to']; if($subject && $to && $message) { $insert = mysql_query("INSERT INTO `messages` (`site`, `subject`, `body`, `status`, `date`, `to`, `from`) VALUES($Z, $subject, $message, $status, $date, $to, '{$_COOKIE['ELv2']}')"); $insert = mysql_query("INSERT INTO `messages` (`site`, `subject`, `body`, `status`, `date`, `to`, `from`) VALUES('$Z', '$subject', '$message', '$status', '$date', '$to', '{$_COOKIE['ELv2']}')"); if($insert) { print "<h2>Message Sent</h2><p> Your message has been sent!<P> <a href=\"mail.php?action=inbox\">Back to Inbox"; } else { print mysql_error(); } } else { print "Subject, To User, and Message are required!"; } } // OMG I can read!... below is to view outward images!... DUH! if($a !== 'sview') { $id = $_GET['id']; $us = $_COOKIE['ELv2']; $update = mysql_query("UPDATE `messages` SET status = 'read' WHERE `id`='$id' AND `site`= $Z"); $query = "SELECT * FROM `messages` WHERE `id`='$id' AND `site` = '$Z'"; $sql = mysql_query($query) or die("MySQL Error in query: ".$query."<br />".mysql_error()); while($row = mysql_fetch_array($sql)) { extract($row); print "<h2>" . $subject . "</h2><p> To: " . $to . " <br>From: " . $from . " <br>Date: " . $date . "<p> " . $body . "<p> <form action=\"mail.php?action=sendmsg\" method=\"post\"> <input type=\"hidden\" name=\"to\" value=\"" . $from . "\" class=\"text_box\"> <input type=\"hidden\" name=\"subject\" value=\"RE: " . $subject . "\" class=\"text_box\"> Reply:<br> <textarea rows=\"6\" cols=\"60\" nowrap name=\"message\" class=\"text_box\"> <p><p>Original Message --------------------------- To: " . $to . " From: " . $from . " Date: " . $date . " Message: " . $body . "</textarea><p> <input type=\"submit\" value=\" Send Reply \" class=\"text_box\"></form>"; } } /* EXTERMINATE!... Delete messages below HOWEVER, I wish to have it not delete completely from the server, ie. the staff can only see it!*/ if($a == 'delete') { $id = $_GET['id']; $del = mysql_query("DELETE FROM `messages` WHERE `id` = '$id' AND `site` = '$Z'"); if($del) { Header("Location: mail.php?action=inbox"); } else { print mysql_error(); } } //Below is to view inbox mail if($a !== 'view') { $id = $_GET['id']; $us = $_COOKIE['ELv2']; $update = mysql_query("UPDATE `messages` SET `status`='read' WHERE `id`='$id' AND `site`=$Z"); $query = "SELECT * FROM `messages` WHERE `id`='$id' AND `site` = '$Z'"; $sql = mysql_query($query) or die("MySQL Error in query: ".$query."<br />".mysql_error()); while($row = mysql_fetch_array($sql)) { extract($row); print "<h2>" . $subject . "</h2><p> To: " . $to . "<br> From: " . $from . "<br> Date: " . $date . "<p> <form action=\"mail.php?action=sendmsg\" method=\"post\"> <input type=\"hidden\" name=\"to\" value=\"" . $from . "\" class=\"text_box\"> <input type=\"hidden\" name=\"subject\" value=\"RE: " . $subject . "\" class=\"text_box\"> Message:<br> <textarea rows=\"6\" cols=\"60\" nowrap name=\"message\" class=\"text_box\"> $body </textarea><p>"; } } } include("footer.php"); ?> Quote Link to comment Share on other sites More sharing options...
eaglelegend Posted May 2, 2008 Author Share Posted May 2, 2008 Ok thank you, that works.! Have you included the earlier code examples you gave? also, the question was actually, how do I have text to say ie. if more than 1 message, you have say "6 new messages" otherwise show nothing, for other pages etc. Unfortunately taking a != (!) off shows both "view" pages, for inbox and out, and dont show the outbox on the inbox viewer... as above... Quote Link to comment Share on other sites More sharing options...
eaglelegend Posted May 2, 2008 Author Share Posted May 2, 2008 also I just found out, the reply thing don't work either, still the same... Quote Link to comment Share on other sites More sharing options...
MadTechie Posted May 2, 2008 Share Posted May 2, 2008 heres a quick clean up i have probably messed it up but i can't test it <?php include("header.php"); include("members.php"); $a = $_GET['action']; $u = $_COOKIE['ELv2']; $id = $_GET['id']; ?> <h2>Message Center</h2> <input type='button' value='Send a New Message!' onClick='parent.location="/mail.php?action=newmsg"' class='text_box' style='width: 200px' alt='Send a message!' title='Send a message!'> <input type='button' value='Inbox!' onClick='parent.location="/mail.php?action=inbox"' class='text_box' style='width: 200px' alt='View your recieved mail!' title='View your recieved mail!'> <input type='button' value='Outbox!' onClick='parent.location="/mail.php?action=outbox"' class='text_box' style='width: 200px' alt='View mail you have sent!' title='View mail you have sent!'> <?php switch($a) { case "inbox": print "<br><h1>Inbox</h1><p> <table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" width=\"100%\" bgcolor=\"#000000\"> <tr> <Td bgcolor=\"#dddddd\" class=\"text_box\">Subject</td> <td bgcolor=\"#dddddd\" class=\"text_box\">From</td> <td bgcolor=\"#dddddd\" class=\"text_box\">Date</td> <td bgcolor=\"#dddddd\" class=\"text_box\">Status</td> <td bgcolor=\"#dddddd\" class=\"text_box\">Actions</td> </tr>"; $query = "SELECT * FROM `messages` WHERE `to` = '{$u}' AND `site` = '$Z' ORDER BY `id` DESC"; $sql = mysql_query($query) or die("MySQL Error in query: ".$query."<br />".mysql_error()); while($row = mysql_fetch_array($sql)) { extract($row); print "<tr> <td bgcolor=\"#ffffff\" class=\"other\">" . $subject . "</td> <td bgcolor=\"#ffffff\" class=\"other\">" . $from . "</td> <td bgcolor=\"#ffffff\" class=\"other\">" . $date . "</td> <td bgcolor=\"#ffffff\" class=\"other\">" . $status . "</td> <td bgcolor=\"#ffffff\" class=\"other\"><a href=\"mail.php?action=view&id=" . $id . "\">Read - <a href=\"mail.php?action=delete&id=" . $id . "\">Delete</td> </tr>"; } print "</table>"; break; case "outbox": print "<br><h1>Outbox</h2><p> <table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" width=\"100%\" bgcolor=\"#000000\"> <tr> <Td bgcolor=\"#dddddd\" class=\"text_box\">Subject</td> <td bgcolor=\"#dddddd\" class=\"text_box\">To</td> <td bgcolor=\"#dddddd\" class=\"text_box\">Date</td> <td bgcolor=\"#dddddd\" class=\"text_box\">Status</td> <td bgcolor=\"#dddddd\" class=\"text_box\">Actions</td> </tr>"; $query = "SELECT * FROM `messages` WHERE `from` = '{$u}' AND `site` = '$Z' ORDER BY `id` DESC"; $sql = mysql_query($query) or die("MySQL Error in query: ".$query."<br />".mysql_error()); while($row = mysql_fetch_array($sql)) { extract($row); print "<tr> <td bgcolor=\"#ffffff\" class=\"other\">$subject</td> <td bgcolor=\"#ffffff\" class=\"other\">$to</td> <td bgcolor=\"#ffffff\" class=\"other\">$date</td> <td bgcolor=\"#ffffff\" class=\"other\">$status</td> <td bgcolor=\"#ffffff\" class=\"other\"><a href=\"mail.php?action=sview&id=$id\">Read - <a href=\"mail.php?action=delete&id=$id\">Delete</td> </tr>"; } print "</table>"; break; case "delete": $del = mysql_query("DELETE FROM `messages` WHERE `id` = '$id' AND `site` = '$Z'"); if($del) { Header("Location: mail.php?action=inbox"); } else { print mysql_error(); } break; case "view": $update = mysql_query("UPDATE `messages` SET `status`='read' WHERE `id`='$id' AND `site`=$Z"); $query = "SELECT * FROM `messages` WHERE `id`='$id' AND `site` = '$Z'"; $sql = mysql_query($query) or die("MySQL Error in query: ".$query."<br />".mysql_error()); while($row = mysql_fetch_array($sql)) { extract($row); print "<h2>$subject</h2><p> To: $to<br> From: $from<br> Date: $date<p> <form action=\"mail.php?action=sendmsg\" method=\"post\"> <input type=\"hidden\" name=\"to\" value=\"$from\" class=\"text_box\"> <input type=\"hidden\" name=\"subject\" value=\"RE: $subject\" class=\"text_box\"> Message:<br> <textarea rows=\"6\" cols=\"60\" nowrap name=\"message\" class=\"text_box\"> $body </textarea><p>"; } break; case "view": $update = mysql_query("UPDATE `messages` SET `status`='read' WHERE `id`='$id' AND `site`=$Z"); $query = "SELECT * FROM `messages` WHERE `id`='$id' AND `site` = '$Z'"; $sql = mysql_query($query) or die("MySQL Error in query: ".$query."<br />".mysql_error()); while($row = mysql_fetch_array($sql)) { extract($row); print "<h2>$subject</h2><p> To: $to<br> From: $from<br> Date: $date<p> <form action=\"mail.php?action=sendmsg\" method=\"post\"> <input type=\"hidden\" name=\"to\" value=\"$from\" class=\"text_box\"> <input type=\"hidden\" name=\"subject\" value=\"RE: $subject\" class=\"text_box\"> Message:<br> <textarea rows=\"6\" cols=\"60\" nowrap name=\"message\" class=\"text_box\"> $body </textarea><p>"; } break; case "sendmsg": if($_POST['type'] == 1) { $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/plain; charset=iso-8859-1\r\n"; $headers .= "To: ".trim($_POST['to'])."\r\n"; $headers .= "From: ".trim($_POST['from'])."\r\n"; $headers .= "Reply-To: ".trim($email)."\r\nnew;reply-to: ".trim($email)."\r\n"; @mail(trim($_POST['to']), trim($_POST['subject']), $_POST['message'], $headers); echo("Mail sent to ".trim($_POST['to']) ); }elseif ($_POST['type'] == 2) { $subject = $_POST['subject']; $message = $_POST['message']; $date = date("m/d/y"); $status = "unread"; $to = $_POST['to']; if($subject && $to && $message) { $insert = mysql_query("INSERT INTO `messages` (`site`, `subject`, `body`, `status`, `date`, `to`, `from`) VALUES('$Z', '$subject', '$message', '$status', '$date', '$to', '$u')"); if($insert) { print "<h2>Message Sent</h2><p> Your message has been sent!<P> <a href=\"mail.php?action=inbox\">Back to Inbox"; }else { print mysql_error(); } } else { print "Subject, To User, and Message are required!"; } } break; case "sview": $update = mysql_query("UPDATE `messages` SET status = 'read' WHERE `id`='$id' AND `site`= $Z"); $query = "SELECT * FROM `messages` WHERE `id`='$id' AND `site` = '$Z'"; $sql = mysql_query($query) or die("MySQL Error in query: ".$query."<br />".mysql_error()); while($row = mysql_fetch_array($sql)) { extract($row); print "<h2>$subject</h2><p> To: $to <br>From: $from <br>Date: $date<p> $body<p> <form action=\"mail.php?action=sendmsg\" method=\"post\"> <input type=\"hidden\" name=\"to\" value=\"$from\" class=\"text_box\"> <input type=\"hidden\" name=\"subject\" value=\"RE: $subject\" class=\"text_box\"> Reply:<br> <textarea rows=\"6\" cols=\"60\" nowrap name=\"message\" class=\"text_box\"> <p><p>Original Message --------------------------- To: $to From: $from Date: $date Message: $body</textarea><p> <input type=\"submit\" value=\" Send Reply \" class=\"text_box\"></form>"; } break; default: $query = "SELECT count(*) as msgs FROM `messages` WHERE `to` = '$u' AND `site` = '$Z' "; $sql = mysql_query($query) or die("MySQL Error in query: ".$query."<br />".mysql_error()); $msg = mysql_fetch_array($sql); echo "You have {$msg['msgs']} messages"; echo "<h1>Send Message</h1><p> <form action=\"mail.php?action=sendmsg\" method=\"post\">"; echo "<input type=\"radio\" name=\"type\" value=\"1\" class=\"text_box\" alt=\"Click here if you are sending your message outside this site via email\" title=\"Click here if you are sending your message outside this site via email\"> Email <input type=\"radio\" name=\"type\" value=\"2\" checked class=\"text_box\" alt=\"Click here if you are sending a message within this site and NOT via email!\" title=\"Click here if you are sending a message within this site and NOT via email!\"> Private Message <br> To: <br> <input type=\"text\" name=\"to\" class=\"text_box\" alt=\"Who do you want to send your message to?\" title=\"Who do you want to send your message to?\"><p> From:<br> <select name=\"from\" size=\"1\" class=\"text_box\" alt=\"Please choose where your sending from!\" title=\"Please choose where you are sending from!\">"; $sql = mysql_query("SELECT * FROM `members` WHERE `username`='$u'"); while($row = mysql_fetch_array($sql)) { $us = $row["username"]; print "<option value=\"$us\">$us</option> <option value=\"$us@eaglelegend.com\">$us@eaglelegend.com</option>"; } print "</select><p> Subject:<br> <input type=\"text\" name=\"subject\" size=\"30\" class=\"text_box\" alt=\"What is the title/subject of your message?\" title=\"What is the title/subject of your message?\"><p> Message:<br> <textarea rows=\"6\" cols=\"60\" nowrap name=\"message\" class=\"text_box\" alt=\"Please enter your message!\" title=\"Please enter your message!\"></textarea><p> <input type=\"submit\" value=\" Send Message \" class=\"text_box\" alt=\"Click here to send your message!\" title=\"Click here to send your message!\"></form>"; #$query = "SELECT `email` FROM `members` WHERE `username`='".mysql_escape_string($username)."' LIMIT 1"; break; } include("footer.php"); ?> Quote Link to comment Share on other sites More sharing options...
eaglelegend Posted May 2, 2008 Author Share Posted May 2, 2008 OK, thanks! It still don't show the right status or reply, but the code is still working as it is supposed to... <?php include("header.php"); include("members.php"); $a = $_GET['action']; $u = $_COOKIE['ELv2']; $id = $_GET['id']; ?> <h2>Message Center</h2> <input type='button' value='Send a New Message!' onClick='parent.location="/mail.php?action=newmsg"' class='text_box' style='width: 200px' alt='Send a message!' title='Send a message!'> <input type='button' value='Inbox!' onClick='parent.location="/mail.php?action=inbox"' class='text_box' style='width: 200px' alt='View your recieved mail!' title='View your recieved mail!'> <input type='button' value='Outbox!' onClick='parent.location="/mail.php?action=outbox"' class='text_box' style='width: 200px' alt='View mail you have sent!' title='View mail you have sent!'> <?php switch($a) { case "inbox": print "<br><h1>Inbox</h1><p> <table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" width=\"100%\" bgcolor=\"#000000\"> <tr> <Td bgcolor=\"#dddddd\" class=\"text_box\">Subject</td> <td bgcolor=\"#dddddd\" class=\"text_box\">From</td> <td bgcolor=\"#dddddd\" class=\"text_box\">Date</td> <td bgcolor=\"#dddddd\" class=\"text_box\">Status</td> <td bgcolor=\"#dddddd\" class=\"text_box\">Actions</td> </tr>"; $query = "SELECT * FROM `messages` WHERE `to` = '{$u}' AND `site` = '$Z' ORDER BY `id` DESC"; $sql = mysql_query($query) or die("MySQL Error in query: ".$query."<br />".mysql_error()); while($row = mysql_fetch_array($sql)) { extract($row); print "<tr> <td bgcolor=\"#ffffff\" class=\"other\">" . $subject . "</td> <td bgcolor=\"#ffffff\" class=\"other\">" . $from . "</td> <td bgcolor=\"#ffffff\" class=\"other\">" . $date . "</td> <td bgcolor=\"#ffffff\" class=\"other\">" . $status . "</td> <td bgcolor=\"#ffffff\" class=\"other\"><a href=\"mail.php?action=sview&id=" . $id . "\">Read - <a href=\"mail.php?action=delete&id=" . $id . "\">Delete</td> </tr>"; } print "</table>"; break; case "outbox": print "<br><h1>Outbox</h2><p> <table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" width=\"100%\" bgcolor=\"#000000\"> <tr> <Td bgcolor=\"#dddddd\" class=\"text_box\">Subject</td> <td bgcolor=\"#dddddd\" class=\"text_box\">To</td> <td bgcolor=\"#dddddd\" class=\"text_box\">Date</td> <td bgcolor=\"#dddddd\" class=\"text_box\">Status</td> <td bgcolor=\"#dddddd\" class=\"text_box\">Actions</td> </tr>"; $query = "SELECT * FROM `messages` WHERE `from` = '{$u}' AND `site` = '$Z' ORDER BY `id` DESC"; $sql = mysql_query($query) or die("MySQL Error in query: ".$query."<br />".mysql_error()); while($row = mysql_fetch_array($sql)) { extract($row); print "<tr> <td bgcolor=\"#ffffff\" class=\"other\">$subject</td> <td bgcolor=\"#ffffff\" class=\"other\">$to</td> <td bgcolor=\"#ffffff\" class=\"other\">$date</td> <td bgcolor=\"#ffffff\" class=\"other\">$status</td> <td bgcolor=\"#ffffff\" class=\"other\"><a href=\"mail.php?action=view&id=$id\">Read - <a href=\"mail.php?action=delete&id=$id\">Delete</td> </tr>"; } print "</table>"; break; case "delete": $del = mysql_query("DELETE FROM `messages` WHERE `id` = '$id' AND `site` = '$Z'"); if($del) { Header("Location: mail.php?action=inbox"); } else { print mysql_error(); } break; case "view": $update = mysql_query("UPDATE `messages` SET `status`='read' WHERE `id`='$id' AND `site`=$Z"); $query = "SELECT * FROM `messages` WHERE `id`='$id' AND `site` = '$Z'"; $sql = mysql_query($query) or die("MySQL Error in query: ".$query."<br />".mysql_error()); while($row = mysql_fetch_array($sql)) { extract($row); print "<h2>$subject</h2><p> To: $to<br> From: $from<br> Date: $date<p> <form action=\"mail.php?action=sendmsg\" method=\"post\"> <input type=\"hidden\" name=\"to\" value=\"$from\" class=\"text_box\"> <input type=\"hidden\" name=\"subject\" value=\"RE: $subject\" class=\"text_box\"> Message:<br> <textarea rows=\"6\" cols=\"60\" nowrap name=\"message\" class=\"text_box\"> $body </textarea><p>"; } break; case "view": $update = mysql_query("UPDATE `messages` SET `status`='read' WHERE `id`='$id' AND `site`=$Z"); $query = "SELECT * FROM `messages` WHERE `id`='$id' AND `site` = '$Z'"; $sql = mysql_query($query) or die("MySQL Error in query: ".$query."<br />".mysql_error()); while($row = mysql_fetch_array($sql)) { extract($row); print "<h2>$subject</h2><p> To: $to<br> From: $from<br> Date: $date<p> <form action=\"mail.php?action=sendmsg\" method=\"post\"> <input type=\"hidden\" name=\"to\" value=\"$from\" class=\"text_box\"> <input type=\"hidden\" name=\"subject\" value=\"RE: $subject\" class=\"text_box\"> Message:<br> <textarea rows=\"6\" cols=\"60\" nowrap name=\"message\" class=\"text_box\"> $body </textarea><p>"; } break; case "sendmsg": if($_POST['type'] == 1) { $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/plain; charset=iso-8859-1\r\n"; $headers .= "To: ".trim($_POST['to'])."\r\n"; $headers .= "From: ".trim($_POST['from'])."\r\n"; $headers .= "Reply-To: ".trim($email)."\r\nnew;reply-to: ".trim($email)."\r\n"; @mail(trim($_POST['to']), trim($_POST['subject']), $_POST['message'], $headers); echo("Mail sent to ".trim($_POST['to']) ); }elseif ($_POST['type'] == 2) { $subject = $_POST['subject']; $message = $_POST['message']; $date = date("m/d/y"); $status = "unread"; $to = $_POST['to']; if($subject && $to && $message) { $insert = mysql_query("INSERT INTO `messages` (`site`, `subject`, `body`, `status`, `date`, `to`, `from`) VALUES('$Z', '$subject', '$message', '$status', '$date', '$to', '$u')"); if($insert) { print "<h2>Message Sent</h2><p> Your message has been sent!<P> <a href=\"mail.php?action=inbox\">Back to Inbox"; }else { print mysql_error(); } } else { print "Subject, To User, and Message are required!"; } } break; case "sview": $update = mysql_query("UPDATE `messages` SET status = 'read' WHERE `id`='$id' AND `site`= $Z"); $query = "SELECT * FROM `messages` WHERE `id`='$id' AND `site` = '$Z'"; $sql = mysql_query($query) or die("MySQL Error in query: ".$query."<br />".mysql_error()); while($row = mysql_fetch_array($sql)) { extract($row); print "<h2>$subject</h2><p> To: $to <br>From: $from <br>Date: $date<p> $body<p> <form action=\"mail.php?action=sendmsg\" method=\"post\"> <input type=\"hidden\" name=\"to\" value=\"$from\" class=\"text_box\"> <input type=\"hidden\" name=\"subject\" value=\"RE: $subject\" class=\"text_box\"> Reply:<br> <textarea rows=\"6\" cols=\"60\" nowrap name=\"message\" class=\"text_box\"> <p><p>Original Message --------------------------- To: $to From: $from Date: $date Message: $body</textarea><p> <input type=\"submit\" value=\" Send Reply \" class=\"text_box\"></form>"; } break; default: $query = "SELECT count(*) as msgs FROM `messages` WHERE `to` = '$u' AND `site` = '$Z' "; $sql = mysql_query($query) or die("MySQL Error in query: ".$query."<br />".mysql_error()); $msg = mysql_fetch_array($sql); echo "You have {$msg['msgs']} messages"; echo "<h1>Send Message</h1><p> <form action=\"mail.php?action=sendmsg\" method=\"post\">"; echo "<input type=\"radio\" name=\"type\" value=\"1\" class=\"text_box\" alt=\"Click here if you are sending your message outside this site via email\" title=\"Click here if you are sending your message outside this site via email\"> Email <input type=\"radio\" name=\"type\" value=\"2\" checked class=\"text_box\" alt=\"Click here if you are sending a message within this site and NOT via email!\" title=\"Click here if you are sending a message within this site and NOT via email!\"> Private Message <br> To: <br> <input type=\"text\" name=\"to\" class=\"text_box\" alt=\"Who do you want to send your message to?\" title=\"Who do you want to send your message to?\"><p> From:<br> <select name=\"from\" size=\"1\" class=\"text_box\" alt=\"Please choose where your sending from!\" title=\"Please choose where you are sending from!\">"; $sql = mysql_query("SELECT * FROM `members` WHERE `username`='$u'"); while($row = mysql_fetch_array($sql)) { $us = $row["username"]; print "<option value=\"$us\">$us</option> <option value=\"$us@eaglelegend.com\">$us@eaglelegend.com</option>"; } print "</select><p> Subject:<br> <input type=\"text\" name=\"subject\" size=\"30\" class=\"text_box\" alt=\"What is the title/subject of your message?\" title=\"What is the title/subject of your message?\"><p> Message:<br> <textarea rows=\"6\" cols=\"60\" nowrap name=\"message\" class=\"text_box\" alt=\"Please enter your message!\" title=\"Please enter your message!\"></textarea><p> <input type=\"submit\" value=\" Send Message \" class=\"text_box\" alt=\"Click here to send your message!\" title=\"Click here to send your message!\"></form>"; #$query = "SELECT `email` FROM `members` WHERE `username`='".mysql_escape_string($username)."' LIMIT 1"; break; } include("footer.php"); ?> Quote Link to comment Share on other sites More sharing options...
MadTechie Posted May 4, 2008 Share Posted May 4, 2008 for the reply update <input type=\"hidden\" name=\"to\" value=\"$from\" class=\"text_box\"> <input type=\"hidden\" name=\"subject\" value=\"RE: $subject\" class=\"text_box\"> to <input type=\"hidden\" name=\"to\" value=\"$from\" class=\"text_box\"> <input type=\"hidden\" name=\"subject\" value=\"RE: $subject\" class=\"text_box\"> <input type=\"hidden\" name=\"type\" value=\"2\" class=\"text_box\"> Quote Link to comment Share on other sites More sharing options...
eaglelegend Posted May 5, 2008 Author Share Posted May 5, 2008 eh, im sorry... it hassent helped at all... still leads to a blank page. Quote Link to comment Share on other sites More sharing options...
MadTechie Posted May 5, 2008 Share Posted May 5, 2008 you have two view cases remove one (make sure the other has the <input type=\"hidden\" name=\"type\" value=\"2\" class=\"text_box\"> in it Quote Link to comment Share on other sites More sharing options...
eaglelegend Posted May 5, 2008 Author Share Posted May 5, 2008 could you explain a bit further please? thanks, thanks for your efforts to help me out so far, and to spare some of your time to help people like me out im VERY greatful thanks Current Code: <?php include("header.php"); include("members.php"); $a = $_GET['action']; $u = $_COOKIE['ELv2']; $id = $_GET['id']; ?> <h2>Message Center</h2> <input type='button' value='Send a New Message!' onClick='parent.location="/mail.php?action=newmsg"' class='text_box' style='width: 200px' alt='Send a message!' title='Send a message!'> <input type='button' value='Inbox!' onClick='parent.location="/mail.php?action=inbox"' class='text_box' style='width: 200px' alt='View your recieved mail!' title='View your recieved mail!'> <input type='button' value='Outbox!' onClick='parent.location="/mail.php?action=outbox"' class='text_box' style='width: 200px' alt='View mail you have sent!' title='View mail you have sent!'> <?php switch($a) { case "inbox": print "<br><h1>Inbox</h1><p> <table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" width=\"100%\" bgcolor=\"#000000\"> <tr> <Td bgcolor=\"#dddddd\" class=\"text_box\">Subject</td> <td bgcolor=\"#dddddd\" class=\"text_box\">From</td> <td bgcolor=\"#dddddd\" class=\"text_box\">Date</td> <td bgcolor=\"#dddddd\" class=\"text_box\">Status</td> <td bgcolor=\"#dddddd\" class=\"text_box\">Actions</td> </tr>"; $query = "SELECT * FROM `messages` WHERE `to` = '{$u}' AND `site` = '$Z' ORDER BY `id` DESC"; $sql = mysql_query($query) or die("MySQL Error in query: ".$query."<br />".mysql_error()); while($row = mysql_fetch_array($sql)) { extract($row); print "<tr> <td bgcolor=\"#ffffff\" class=\"other\">" . $subject . "</td> <td bgcolor=\"#ffffff\" class=\"other\">" . $from . "</td> <td bgcolor=\"#ffffff\" class=\"other\">" . $date . "</td> <td bgcolor=\"#ffffff\" class=\"other\">" . $status . "</td> <td bgcolor=\"#ffffff\" class=\"other\"><a href=\"mail.php?action=sview&id=" . $id . "\">Read - <a href=\"mail.php?action=delete&id=" . $id . "\">Delete</td> </tr>"; } print "</table>"; break; case "outbox": print "<br><h1>Outbox</h2><p> <table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" width=\"100%\" bgcolor=\"#000000\"> <tr> <Td bgcolor=\"#dddddd\" class=\"text_box\">Subject</td> <td bgcolor=\"#dddddd\" class=\"text_box\">To</td> <td bgcolor=\"#dddddd\" class=\"text_box\">Date</td> <td bgcolor=\"#dddddd\" class=\"text_box\">Status</td> <td bgcolor=\"#dddddd\" class=\"text_box\">Actions</td> </tr>"; $query = "SELECT * FROM `messages` WHERE `from` = '{$u}' AND `site` = '$Z' ORDER BY `id` DESC"; $sql = mysql_query($query) or die("MySQL Error in query: ".$query."<br />".mysql_error()); while($row = mysql_fetch_array($sql)) { extract($row); print "<tr> <td bgcolor=\"#ffffff\" class=\"other\">$subject</td> <td bgcolor=\"#ffffff\" class=\"other\">$to</td> <td bgcolor=\"#ffffff\" class=\"other\">$date</td> <td bgcolor=\"#ffffff\" class=\"other\">$status</td> <td bgcolor=\"#ffffff\" class=\"other\"><a href=\"mail.php?action=view&id=$id\">Read - <a href=\"mail.php?action=delete&id=$id\">Delete</td> </tr>"; } print "</table>"; break; case "delete": $del = mysql_query("DELETE FROM `messages` WHERE `id` = '$id' AND `site` = '$Z'"); if($del) { Header("Location: mail.php?action=inbox"); } else { print mysql_error(); } break; case "view": $update = mysql_query("UPDATE `messages` SET `status`='read' WHERE `id`='$id' AND `site`=$Z"); $query = "SELECT * FROM `messages` WHERE `id`='$id' AND `site` = '$Z'"; $sql = mysql_query($query) or die("MySQL Error in query: ".$query."<br />".mysql_error()); while($row = mysql_fetch_array($sql)) { extract($row); print "<h2>$subject</h2><p> To: $to<br> From: $from<br> Date: $date<p> <form action=\"mail.php?action=sendmsg\" method=\"post\"> <input type=\"hidden\" name=\"to\" value=\"$from\" class=\"text_box\"> <input type=\"hidden\" name=\"subject\" value=\"RE: $subject\" class=\"text_box\"> <input type=\"hidden\" name=\"type\" value=\"2\" class=\"text_box\"> Message:<br> <textarea rows=\"6\" cols=\"60\" nowrap name=\"message\" class=\"text_box\"> $body </textarea><p>"; } break; case "view": $update = mysql_query("UPDATE `messages` SET `status`='read' WHERE `id`='$id' AND `site`=$Z"); $query = "SELECT * FROM `messages` WHERE `id`='$id' AND `site` = '$Z'"; $sql = mysql_query($query) or die("MySQL Error in query: ".$query."<br />".mysql_error()); while($row = mysql_fetch_array($sql)) { extract($row); print "<h2>$subject</h2><p> To: $to<br> From: $from<br> Date: $date<p> <form action=\"mail.php?action=sendmsg\" method=\"post\"> <input type=\"hidden\" name=\"to\" value=\"$from\" class=\"text_box\"> <input type=\"hidden\" name=\"subject\" value=\"RE: $subject\" class=\"text_box\"> Message:<br> <textarea rows=\"6\" cols=\"60\" nowrap name=\"message\" class=\"text_box\"> $body </textarea><p>"; } break; case "sendmsg": if($_POST['type'] == 1) { $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/plain; charset=iso-8859-1\r\n"; $headers .= "To: ".trim($_POST['to'])."\r\n"; $headers .= "From: ".trim($_POST['from'])."\r\n"; $headers .= "Reply-To: ".trim($email)."\r\nnew;reply-to: ".trim($email)."\r\n"; @mail(trim($_POST['to']), trim($_POST['subject']), $_POST['message'], $headers); echo("Mail sent to ".trim($_POST['to']) ); }elseif ($_POST['type'] == 2) { $subject = $_POST['subject']; $message = $_POST['message']; $date = date("m/d/y"); $status = "unread"; $to = $_POST['to']; if($subject && $to && $message) { $insert = mysql_query("INSERT INTO `messages` (`site`, `subject`, `body`, `status`, `date`, `to`, `from`) VALUES('$Z', '$subject', '$message', '$status', '$date', '$to', '$u')"); if($insert) { print "<h2>Message Sent</h2><p> Your message has been sent!<P> <a href=\"mail.php?action=inbox\">Back to Inbox"; }else { print mysql_error(); } } else { print "Subject, To User, and Message are required!"; } } break; case "sview": $update = mysql_query("UPDATE `messages` SET status = 'read' WHERE `id`='$id' AND `site`= $Z"); $query = "SELECT * FROM `messages` WHERE `id`='$id' AND `site` = '$Z'"; $sql = mysql_query($query) or die("MySQL Error in query: ".$query."<br />".mysql_error()); while($row = mysql_fetch_array($sql)) { extract($row); print "<h2>$subject</h2><p> To: $to <br>From: $from <br>Date: $date<p> $body<p> <form action=\"mail.php?action=sendmsg\" method=\"post\"> <input type=\"hidden\" name=\"to\" value=\"$from\" class=\"text_box\"> <input type=\"hidden\" name=\"subject\" value=\"RE: $subject\" class=\"text_box\"> Reply:<br> <textarea rows=\"6\" cols=\"60\" nowrap name=\"message\" class=\"text_box\"> <p><p>Original Message --------------------------- To: $to From: $from Date: $date Message: $body</textarea><p> <input type=\"submit\" value=\" Send Reply \" class=\"text_box\"></form>"; } break; default: $query = "SELECT count(*) as msgs FROM `messages` WHERE `to` = '$u' AND `site` = '$Z' "; $sql = mysql_query($query) or die("MySQL Error in query: ".$query."<br />".mysql_error()); $msg = mysql_fetch_array($sql); echo "You have {$msg['msgs']} messages"; echo "<h1>Send Message</h1><p> <form action=\"mail.php?action=sendmsg\" method=\"post\">"; echo "<input type=\"radio\" name=\"type\" value=\"1\" class=\"text_box\" alt=\"Click here if you are sending your message outside this site via email\" title=\"Click here if you are sending your message outside this site via email\"> Email <input type=\"radio\" name=\"type\" value=\"2\" checked class=\"text_box\" alt=\"Click here if you are sending a message within this site and NOT via email!\" title=\"Click here if you are sending a message within this site and NOT via email!\"> Private Message <br> To: <br> <input type=\"text\" name=\"to\" class=\"text_box\" alt=\"Who do you want to send your message to?\" title=\"Who do you want to send your message to?\"><p> From:<br> <select name=\"from\" size=\"1\" class=\"text_box\" alt=\"Please choose where your sending from!\" title=\"Please choose where you are sending from!\">"; $sql = mysql_query("SELECT * FROM `members` WHERE `username`='$u'"); while($row = mysql_fetch_array($sql)) { $us = $row["username"]; print "<option value=\"$us\">$us</option> <option value=\"$us@eaglelegend.com\">$us@eaglelegend.com</option>"; } print "</select><p> Subject:<br> <input type=\"text\" name=\"subject\" size=\"30\" class=\"text_box\" alt=\"What is the title/subject of your message?\" title=\"What is the title/subject of your message?\"><p> Message:<br> <textarea rows=\"6\" cols=\"60\" nowrap name=\"message\" class=\"text_box\" alt=\"Please enter your message!\" title=\"Please enter your message!\"></textarea><p> <input type=\"submit\" value=\" Send Message \" class=\"text_box\" alt=\"Click here to send your message!\" title=\"Click here to send your message!\"></form>"; #$query = "SELECT `email` FROM `members` WHERE `username`='".mysql_escape_string($username)."' LIMIT 1"; break; } include("footer.php"); ?> Quote Link to comment Share on other sites More sharing options...
MadTechie Posted May 5, 2008 Share Posted May 5, 2008 try this should atleast give a debug message.. its a shame i will be writing my own PM system for a project in about 15-30 days.. <?php include("header.php"); include("members.php"); $a = $_GET['action']; $u = $_COOKIE['ELv2']; $id = $_GET['id']; ?> <h2>Message Center</h2> <input type='button' value='Send a New Message!' onClick='parent.location="/mail.php?action=newmsg"' class='text_box' style='width: 200px' alt='Send a message!' title='Send a message!'> <input type='button' value='Inbox!' onClick='parent.location="/mail.php?action=inbox"' class='text_box' style='width: 200px' alt='View your recieved mail!' title='View your recieved mail!'> <input type='button' value='Outbox!' onClick='parent.location="/mail.php?action=outbox"' class='text_box' style='width: 200px' alt='View mail you have sent!' title='View mail you have sent!'> <?php switch($a) { case "inbox": print "<br><h1>Inbox</h1><p> <table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" width=\"100%\" bgcolor=\"#000000\"> <tr> <Td bgcolor=\"#dddddd\" class=\"text_box\">Subject</td> <td bgcolor=\"#dddddd\" class=\"text_box\">From</td> <td bgcolor=\"#dddddd\" class=\"text_box\">Date</td> <td bgcolor=\"#dddddd\" class=\"text_box\">Status</td> <td bgcolor=\"#dddddd\" class=\"text_box\">Actions</td> </tr>"; $query = "SELECT * FROM `messages` WHERE `to` = '{$u}' AND `site` = '$Z' ORDER BY `id` DESC"; $sql = mysql_query($query) or die("MySQL Error in query: ".$query."<br />".mysql_error()); while($row = mysql_fetch_array($sql)) { extract($row); print "<tr> <td bgcolor=\"#ffffff\" class=\"other\">" . $subject . "</td> <td bgcolor=\"#ffffff\" class=\"other\">" . $from . "</td> <td bgcolor=\"#ffffff\" class=\"other\">" . $date . "</td> <td bgcolor=\"#ffffff\" class=\"other\">" . $status . "</td> <td bgcolor=\"#ffffff\" class=\"other\"><a href=\"mail.php?action=sview&id=" . $id . "\">Read - <a href=\"mail.php?action=delete&id=" . $id . "\">Delete</td> </tr>"; } print "</table>"; break; case "outbox": print "<br><h1>Outbox</h2><p> <table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" width=\"100%\" bgcolor=\"#000000\"> <tr> <Td bgcolor=\"#dddddd\" class=\"text_box\">Subject</td> <td bgcolor=\"#dddddd\" class=\"text_box\">To</td> <td bgcolor=\"#dddddd\" class=\"text_box\">Date</td> <td bgcolor=\"#dddddd\" class=\"text_box\">Status</td> <td bgcolor=\"#dddddd\" class=\"text_box\">Actions</td> </tr>"; $query = "SELECT * FROM `messages` WHERE `from` = '{$u}' AND `site` = '$Z' ORDER BY `id` DESC"; $sql = mysql_query($query) or die("MySQL Error in query: ".$query."<br />".mysql_error()); while($row = mysql_fetch_array($sql)) { extract($row); print "<tr> <td bgcolor=\"#ffffff\" class=\"other\">$subject</td> <td bgcolor=\"#ffffff\" class=\"other\">$to</td> <td bgcolor=\"#ffffff\" class=\"other\">$date</td> <td bgcolor=\"#ffffff\" class=\"other\">$status</td> <td bgcolor=\"#ffffff\" class=\"other\"><a href=\"mail.php?action=view&id=$id\">Read - <a href=\"mail.php?action=delete&id=$id\">Delete</td> </tr>"; } print "</table>"; break; case "delete": $del = mysql_query("DELETE FROM `messages` WHERE `id` = '$id' AND `site` = '$Z'"); if($del) { Header("Location: mail.php?action=inbox"); } else { print mysql_error(); } break; case "view": $update = mysql_query("UPDATE `messages` SET `status`='read' WHERE `id`='$id' AND `site`=$Z"); $query = "SELECT * FROM `messages` WHERE `id`='$id' AND `site` = '$Z'"; $sql = mysql_query($query) or die("MySQL Error in query: ".$query."<br />".mysql_error()); while($row = mysql_fetch_array($sql)) { extract($row); print "<h2>$subject</h2><p> To: $to<br> From: $from<br> Date: $date<p> <form action=\"mail.php?action=sendmsg\" method=\"post\"> <input type=\"hidden\" name=\"to\" value=\"$from\" class=\"text_box\"> <input type=\"hidden\" name=\"subject\" value=\"RE: $subject\" class=\"text_box\"> <input type=\"hidden\" name=\"type\" value=\"2\" class=\"text_box\"> Message:<br> <textarea rows=\"6\" cols=\"60\" nowrap name=\"message\" class=\"text_box\"> $body </textarea><p>"; } break; case "sendmsg": echo "debug:Type="; var_dump($_POST['type']); if($_POST['type'] == "1") { $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/plain; charset=iso-8859-1\r\n"; $headers .= "To: ".trim($_POST['to'])."\r\n"; $headers .= "From: ".trim($_POST['from'])."\r\n"; $headers .= "Reply-To: ".trim($email)."\r\nnew;reply-to: ".trim($email)."\r\n"; @mail(trim($_POST['to']), trim($_POST['subject']), $_POST['message'], $headers); echo("Mail sent to ".trim($_POST['to']) ); }elseif ($_POST['type'] == "2") { $subject = $_POST['subject']; $message = $_POST['message']; $date = date("m/d/y"); $status = "unread"; $to = $_POST['to']; if($subject && $to && $message) { $insert = mysql_query("INSERT INTO `messages` (`site`, `subject`, `body`, `status`, `date`, `to`, `from`) VALUES('$Z', '$subject', '$message', '$status', '$date', '$to', '$u')"); if($insert) { print "<h2>Message Sent</h2><p> Your message has been sent!<P> <a href=\"mail.php?action=inbox\">Back to Inbox"; }else { print mysql_error(); } } else { print "Subject, To User, and Message are required!"; } } break; case "sview": $update = mysql_query("UPDATE `messages` SET status = 'read' WHERE `id`='$id' AND `site`= $Z"); $query = "SELECT * FROM `messages` WHERE `id`='$id' AND `site` = '$Z'"; $sql = mysql_query($query) or die("MySQL Error in query: ".$query."<br />".mysql_error()); while($row = mysql_fetch_array($sql)) { extract($row); print "<h2>$subject</h2><p> To: $to <br>From: $from <br>Date: $date<p> $body<p> <form action=\"mail.php?action=sendmsg\" method=\"post\"> <input type=\"hidden\" name=\"to\" value=\"$from\" class=\"text_box\"> <input type=\"hidden\" name=\"type\" value=\"2\" class=\"text_box\"> <input type=\"hidden\" name=\"subject\" value=\"RE: $subject\" class=\"text_box\"> Reply:<br> <textarea rows=\"6\" cols=\"60\" nowrap name=\"message\" class=\"text_box\"> <p><p>Original Message --------------------------- To: $to From: $from Date: $date Message: $body</textarea><p> <input type=\"submit\" value=\" Send Reply \" class=\"text_box\"></form>"; } break; default: $query = "SELECT count(*) as msgs FROM `messages` WHERE `to` = '$u' AND `site` = '$Z' "; $sql = mysql_query($query) or die("MySQL Error in query: ".$query."<br />".mysql_error()); $msg = mysql_fetch_array($sql); echo "You have {$msg['msgs']} messages"; echo "<h1>Send Message</h1><p> <form action=\"mail.php?action=sendmsg\" method=\"post\">"; echo "<input type=\"radio\" name=\"type\" value=\"1\" class=\"text_box\" alt=\"Click here if you are sending your message outside this site via email\" title=\"Click here if you are sending your message outside this site via email\"> Email <input type=\"radio\" name=\"type\" value=\"2\" checked class=\"text_box\" alt=\"Click here if you are sending a message within this site and NOT via email!\" title=\"Click here if you are sending a message within this site and NOT via email!\"> Private Message <br> To: <br> <input type=\"text\" name=\"to\" class=\"text_box\" alt=\"Who do you want to send your message to?\" title=\"Who do you want to send your message to?\"><p> From:<br> <select name=\"from\" size=\"1\" class=\"text_box\" alt=\"Please choose where your sending from!\" title=\"Please choose where you are sending from!\">"; $sql = mysql_query("SELECT * FROM `members` WHERE `username`='$u'"); while($row = mysql_fetch_array($sql)) { $us = $row["username"]; print "<option value=\"$us\">$us</option> <option value=\"$us@eaglelegend.com\">$us@eaglelegend.com</option>"; } print "</select><p> Subject:<br> <input type=\"text\" name=\"subject\" size=\"30\" class=\"text_box\" alt=\"What is the title/subject of your message?\" title=\"What is the title/subject of your message?\"><p> Message:<br> <textarea rows=\"6\" cols=\"60\" nowrap name=\"message\" class=\"text_box\" alt=\"Please enter your message!\" title=\"Please enter your message!\"></textarea><p> <input type=\"submit\" value=\" Send Message \" class=\"text_box\" alt=\"Click here to send your message!\" title=\"Click here to send your message!\"></form>"; #$query = "SELECT `email` FROM `members` WHERE `username`='".mysql_escape_string($username)."' LIMIT 1"; break; } include("footer.php"); ?> Quote Link to comment Share on other sites More sharing options...
eaglelegend Posted May 5, 2008 Author Share Posted May 5, 2008 Great thanks!, that works . now, it does however show some writing in the corner, around above sent message = debug:Type=string(1) "2" . Now thank you again, could you explain what that "debug" thing is all about? is it supposed to be there? Apart from that the unread still dont show as read, if the user HAS read it... EDIT, sorry about that debug thing, I just saw you NOW I posted this and everything, I didnt see it earlier however >_< thanks again./ Quote Link to comment Share on other sites More sharing options...
MadTechie Posted May 5, 2008 Share Posted May 5, 2008 if the reply is working yo can remove the following lines echo "debug:Type="; var_dump($_POST['type']); whats the problem with the unread read thing ? unread still dont show as read ?? Quote Link to comment Share on other sites More sharing options...
eaglelegend Posted May 5, 2008 Author Share Posted May 5, 2008 By default, ALL recieving mail is "unread", however, if a user clicks on it to read it, they will find it to say they havent read it, when they have... thanks again! Quote Link to comment Share on other sites More sharing options...
MadTechie Posted May 5, 2008 Share Posted May 5, 2008 two lines have UPDATE `messages` SET `status`='read' WHERE `id`='$id' AND `site`=$Z update to UPDATE `messages` SET `status`='read' WHERE `id`='$id' AND `site`='$Z' $Z to '$Z' I don't know where $Z is set but this should fix it Quote Link to comment Share on other sites More sharing options...
eaglelegend Posted May 5, 2008 Author Share Posted May 5, 2008 I beleive "$Z" Is something and somewhere in the config file... Quote Link to comment Share on other sites More sharing options...
MadTechie Posted May 5, 2008 Share Posted May 5, 2008 well i assumed it was a int but if its not working then its probably a string thus last post should fix it Quote Link to comment Share on other sites More sharing options...
eaglelegend Posted May 5, 2008 Author Share Posted May 5, 2008 Unfortunately :/ that didnt change anything, I mean its still as it was... here it is now with the new code in it, the one you just updated me with... <?php include("header.php"); include("members.php"); $a = $_GET['action']; $u = $_COOKIE['ELv2']; $id = $_GET['id']; ?> <h2>Message Center</h2> <input type='button' value='Send a New Message!' onClick='parent.location="/mail.php?action=newmsg"' class='text_box' style='width: 200px' alt='Send a message!' title='Send a message!'> <input type='button' value='Inbox!' onClick='parent.location="/mail.php?action=inbox"' class='text_box' style='width: 200px' alt='View your recieved mail!' title='View your recieved mail!'> <input type='button' value='Outbox!' onClick='parent.location="/mail.php?action=outbox"' class='text_box' style='width: 200px' alt='View mail you have sent!' title='View mail you have sent!'> <?php switch($a) { case "inbox": print "<br><h1>Inbox</h1><p> <table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" width=\"100%\" bgcolor=\"#000000\"> <tr> <Td bgcolor=\"#dddddd\" class=\"text_box\">Subject</td> <td bgcolor=\"#dddddd\" class=\"text_box\">From</td> <td bgcolor=\"#dddddd\" class=\"text_box\">Date</td> <td bgcolor=\"#dddddd\" class=\"text_box\">Status</td> <td bgcolor=\"#dddddd\" class=\"text_box\">Actions</td> </tr>"; $query = "SELECT * FROM `messages` WHERE `to` = '{$u}' AND `site` = '$Z' ORDER BY `id` DESC"; $sql = mysql_query($query) or die("MySQL Error in query: ".$query."<br />".mysql_error()); while($row = mysql_fetch_array($sql)) { extract($row); print "<tr> <td bgcolor=\"#ffffff\" class=\"other\">" . $subject . "</td> <td bgcolor=\"#ffffff\" class=\"other\">" . $from . "</td> <td bgcolor=\"#ffffff\" class=\"other\">" . $date . "</td> <td bgcolor=\"#ffffff\" class=\"other\">" . $status . "</td> <td bgcolor=\"#ffffff\" class=\"other\"><a href=\"mail.php?action=sview&id=" . $id . "\">Read - <a href=\"mail.php?action=delete&id=" . $id . "\">Delete</td> </tr>"; } print "</table>"; break; case "outbox": print "<br><h1>Outbox</h2><p> <table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" width=\"100%\" bgcolor=\"#000000\"> <tr> <Td bgcolor=\"#dddddd\" class=\"text_box\">Subject</td> <td bgcolor=\"#dddddd\" class=\"text_box\">To</td> <td bgcolor=\"#dddddd\" class=\"text_box\">Date</td> <td bgcolor=\"#dddddd\" class=\"text_box\">Status</td> <td bgcolor=\"#dddddd\" class=\"text_box\">Actions</td> </tr>"; $query = "SELECT * FROM `messages` WHERE `from` = '{$u}' AND `site` = '$Z' ORDER BY `id` DESC"; $sql = mysql_query($query) or die("MySQL Error in query: ".$query."<br />".mysql_error()); while($row = mysql_fetch_array($sql)) { extract($row); print "<tr> <td bgcolor=\"#ffffff\" class=\"other\">$subject</td> <td bgcolor=\"#ffffff\" class=\"other\">$to</td> <td bgcolor=\"#ffffff\" class=\"other\">$date</td> <td bgcolor=\"#ffffff\" class=\"other\">$status</td> <td bgcolor=\"#ffffff\" class=\"other\"><a href=\"mail.php?action=view&id=$id\">Read - <a href=\"mail.php?action=delete&id=$id\">Delete</td> </tr>"; } print "</table>"; break; case "delete": $del = mysql_query("DELETE FROM `messages` WHERE `id` = '$id' AND `site` = '$Z'"); if($del) { Header("Location: mail.php?action=inbox"); } else { print mysql_error(); } break; case "view": $update = mysql_query("UPDATE `messages` SET `status`='read' WHERE `id`='$id' AND `site`='$Z'"); $query = "SELECT * FROM `messages` WHERE `id`='$id' AND `site` = '$Z'"; $sql = mysql_query($query) or die("MySQL Error in query: ".$query."<br />".mysql_error()); while($row = mysql_fetch_array($sql)) { extract($row); print "<h2>$subject</h2><p> To: $to<br> From: $from<br> Date: $date<p> <form action=\"mail.php?action=sendmsg\" method=\"post\"> <input type=\"hidden\" name=\"to\" value=\"$from\" class=\"text_box\"> <input type=\"hidden\" name=\"subject\" value=\"RE: $subject\" class=\"text_box\"> <input type=\"hidden\" name=\"type\" value=\"2\" class=\"text_box\"> Message:<br> <textarea rows=\"6\" cols=\"60\" nowrap name=\"message\" class=\"text_box\"> $body </textarea><p>"; } break; case "sendmsg": if($_POST['type'] == "1") { $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/plain; charset=iso-8859-1\r\n"; $headers .= "To: ".trim($_POST['to'])."\r\n"; $headers .= "From: ".trim($_POST['from'])."\r\n"; $headers .= "Reply-To: ".trim($email)."\r\nnew;reply-to: ".trim($email)."\r\n"; @mail(trim($_POST['to']), trim($_POST['subject']), $_POST['message'], $headers); echo("Mail sent to ".trim($_POST['to']) ); }elseif ($_POST['type'] == "2") { $subject = $_POST['subject']; $message = $_POST['message']; $date = date("m/d/y"); $status = "unread"; $to = $_POST['to']; if($subject && $to && $message) { $insert = mysql_query("INSERT INTO `messages` (`site`, `subject`, `body`, `status`, `date`, `to`, `from`) VALUES('$Z', '$subject', '$message', '$status', '$date', '$to', '$u')"); if($insert) { print "<h2>Message Sent</h2><p> Your message has been sent!<P> <a href=\"mail.php?action=inbox\">Back to Inbox"; }else { print mysql_error(); } } else { print "Subject, To User, and Message are required!"; } } break; case "sview": $update = mysql_query("UPDATE `messages` SET status = 'read' WHERE `id`='$id' AND `site`= $Z"); $query = "SELECT * FROM `messages` WHERE `id`='$id' AND `site` = '$Z'"; $sql = mysql_query($query) or die("MySQL Error in query: ".$query."<br />".mysql_error()); while($row = mysql_fetch_array($sql)) { extract($row); print "<h2>$subject</h2><p> To: $to <br>From: $from <br>Date: $date<p> $body<p> <form action=\"mail.php?action=sendmsg\" method=\"post\"> <input type=\"hidden\" name=\"to\" value=\"$from\" class=\"text_box\"> <input type=\"hidden\" name=\"type\" value=\"2\" class=\"text_box\"> <input type=\"hidden\" name=\"subject\" value=\"RE: $subject\" class=\"text_box\"> Reply:<br> <textarea rows=\"6\" cols=\"60\" nowrap name=\"message\" class=\"text_box\"> <p><p>Original Message --------------------------- To: $to From: $from Date: $date Message: $body</textarea><p> <input type=\"submit\" value=\" Send Reply \" class=\"text_box\"></form>"; } break; default: $query = "SELECT count(*) as msgs FROM `messages` WHERE `to` = '$u' AND `site` = '$Z' "; $sql = mysql_query($query) or die("MySQL Error in query: ".$query."<br />".mysql_error()); $msg = mysql_fetch_array($sql); echo "You have {$msg['msgs']} messages"; echo "<h1>Send Message</h1><p> <form action=\"mail.php?action=sendmsg\" method=\"post\">"; echo "<input type=\"radio\" name=\"type\" value=\"1\" class=\"text_box\" alt=\"Click here if you are sending your message outside this site via email\" title=\"Click here if you are sending your message outside this site via email\"> Email <input type=\"radio\" name=\"type\" value=\"2\" checked class=\"text_box\" alt=\"Click here if you are sending a message within this site and NOT via email!\" title=\"Click here if you are sending a message within this site and NOT via email!\"> Private Message <br> To: <br> <input type=\"text\" name=\"to\" class=\"text_box\" alt=\"Who do you want to send your message to?\" title=\"Who do you want to send your message to?\"><p> From:<br> <select name=\"from\" size=\"1\" class=\"text_box\" alt=\"Please choose where your sending from!\" title=\"Please choose where you are sending from!\">"; $sql = mysql_query("SELECT * FROM `members` WHERE `username`='$u'"); while($row = mysql_fetch_array($sql)) { $us = $row["username"]; print "<option value=\"$us\">$us</option> <option value=\"$us@eaglelegend.com\">$us@eaglelegend.com</option>"; } print "</select><p> Subject:<br> <input type=\"text\" name=\"subject\" size=\"30\" class=\"text_box\" alt=\"What is the title/subject of your message?\" title=\"What is the title/subject of your message?\"><p> Message:<br> <textarea rows=\"6\" cols=\"60\" nowrap name=\"message\" class=\"text_box\" alt=\"Please enter your message!\" title=\"Please enter your message!\"></textarea><p> <input type=\"submit\" value=\" Send Message \" class=\"text_box\" alt=\"Click here to send your message!\" title=\"Click here to send your message!\"></form>"; #$query = "SELECT `email` FROM `members` WHERE `username`='".mysql_escape_string($username)."' LIMIT 1"; break; } include("footer.php"); ?> Quote Link to comment Share on other sites More sharing options...
MadTechie Posted May 5, 2008 Share Posted May 5, 2008 you missed one case "sview": $update = mysql_query("UPDATE `messages` SET status = 'read' WHERE `id`='$id' AND `site`= $Z"); to case "sview": $update = mysql_query("UPDATE `messages` SET status = 'read' WHERE `id`='$id' AND `site`= '$Z'"); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.