Ok this is my mail script and im having problems with it. It just keeps messing up no matter what I do. >.< I just need it fixed. I would pay someone to fix it. I tried for about 2 hours today and keept running into the same errors.
[ ModEdit - bpat1434 ] - If you're going to post here for help, don't ask for someone to help via IM or email please.
// mail.php
//-----------------------------------
<?php
include 'connect.php';
include 'header.php';
if(!isset($_COOKIE['member_id']))
die('Not logged in, please <a href=\"index.php\">login</a>');
$Player=$_COOKIE['member_id'];
$Query="SELECT * from mail where ID='$Player'";
$Query2=mysql_query($Query) or die("Could not get user stats");
$User=mysql_fetch_array($Query2);
$read = isset($_GET["read"]) ? $_GET["read"] : "";
$view = isset($_GET["view"]) ? $_GET["view"] : "";
$step = isset($_GET["step"]) ? $_GET["step"] : "";
$to = isset($_GET["to"]) ? $_GET["to"] : "";
$subject = isset($_GET["subject"]) ? $_GET["subject"] : "";
$body = isset($_GET["body"]) ? $_GET["body"] : "";
?>
<?php
if (!$view && !$read) {
print "Erylith mailing system.<br><br>
- <a href=\"mail.php?view=inbox\">Inbox</a><br>
- <a href=\"mail.php?view=write\">Compose</a>";
}
if ($view == inbox) {
print "<table>";
print "<tr><td width=75><b><u>From</td><td width=75><b><u>ID</td><td width=100><b><u>Subject</td><td width=50><b><u>Options</td></tr>";
$msel = mysql_query("select * from mail where owner=$Player order by id desc") or die ( mysql_error () );
while ($mail = mysql_fetch_array($msel)) {
print "<tr><td>$mail[sender]</td><td>$mail[senderid]</td><td>$mail[subject]</td><td>- <a href=mail.php?read=$mail[id]>Read</a>";
}
print "</table>";
print "<br>[<a href=mail.php?view=inbox&step=clear>Clear Inbox</a>][<a href=mail.php?view=write>Compose</a>]";
if ($step == clear) {
print "<br>Mail cleared. (<a href=mail.php?view=inbox>refresh</a>)";
mysql_query("delete from mail where owner=$Player");
}
}
if ($view == write) {
print "[<a href=\"mail.php?view=inbox\">Inbox</a>]<br><br>";
print "<table align=\"center\">";
print "<form method=\"post\" action=\"mail.php?view=write&step=send\">";
print "<tr><td>To (ID Number):</td><td><input type=\"text\" name=\"$to\" value=\"to\"></td></tr>";
print "<tr><td>Subject:</td><td><input type=\"text\" name=\"$subject\" value=\"subject\"></td></tr>";
print "<tr><td valign=\"top\">Body:</td><td><textarea name=\"$body\" value=\"body\" rows=\"5\" cols=\"19\"></textarea></td></tr>";
print "<tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"Send\"></td></tr>";
print "</form></table>";
if ($step == send) {
if (empty ($subject)) {
$subject = "None";
}
$rec = mysql_query("select * from Users where ID=$to");
mysql_query("insert into mail (sender,senderid,owner,subject,body) values('$stat[user]','$player',$to,'$subject','$body')") or die("Could not send mail.");
print "You sent mail to $rec[user].";
}
}
if ($read) {
$mail = mysql_fetch_array(mysql_query("select * from mail where id=$read"));
if (empty ($mail[id])) {
print "No such mail.";
include("foot.php");
exit;
}
if ($mail[owner]!= $stat[id]) {
print "That's not your mail.";
include("foot.php");
exit;
}
mysql_query("update mail set unread='T' where id=$mail[id]");
print "<b>$mail[sender]</b> says... \"$mail[body]\".<br><br>[<a href=mail.php?view=inbox>Inbox</a>][<a href=mail.php?view=write>Compose</a>][<a href=mail.php?view=write&to=$mail[senderid]&re=RE:$mail[subject]>Reply</a>]";
}
?>