eaglelegend Posted May 5, 2008 Author Share Posted May 5, 2008 BRILLIANT ) THANK YOU XD I feel so much better now that has been solved, again, I would like to say thank you! OK, one last question, before, you gave me code to tell me how many messages "a" user has in his/her thing, however, what is the code for how many NEW (unread) messages? Quote Link to comment Share on other sites More sharing options...
MadTechie Posted May 5, 2008 Share Posted May 5, 2008 this code <?php 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"; ?> update $query = "SELECT count(*) as msgs FROM `messages` WHERE `to` = '$u' AND `site` = '$Z' "; to this for unread messages $query = "SELECT count(*) as msgs FROM `messages` WHERE `to` = '$u' AND status = 'unread' AND `site` = '$Z' "; EDIT: also update echo "You have {$msg['msgs']} messages"; to echo "You have {$msg['msgs']} NEW messages"; EDIT #2: infact replace <?php 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"; ?> with <?php default: $query = "SELECT count(*) as msgs FROM `messages` WHERE `to` = '$u' AND status = 'unread' AND `site` = '$Z' "; $sql = mysql_query($query) or die("MySQL Error in query: ".$query."<br />".mysql_error()); $msg = mysql_fetch_array($sql); if($msg['msgs'] > 0) { echo "You have <b>{$msg['msgs']}</b> new messages"; } ?> Quote Link to comment Share on other sites More sharing options...
eaglelegend Posted May 5, 2008 Author Share Posted May 5, 2008 Parse error: syntax error, unexpected T_DEFAULT in /misc/39/000/171/334/2/user/web/actorwise.com/nav.php on line 33 Nav.php <?php if($_COOKIE['ELv2']=="") { ?> <h2>Navigation</h2> <input type='button' value='Home' onClick='parent.location="index.php"' class='text_box' style='width: 170px' alt='Click here to go to the main page!' title='Click here to go to the main page!'> <input type='button' value='Register!' onClick='parent.location="register.php"' class='text_box' style='width: 170px' alt='Register!' title='Register!'> <h2>Login</h2> <form action=login.php method=post> Username:<br> <input type="text" name="username" class="text_box" size="15" value="Username" onclick="document.form1.type.value ='''';" onclick="make_blank();" title="Please enter the Username you registered here with." alt="Please enter the Username you registered here with."><p> Password:<br> <input type="password" name="password" class="text_box" size="15" value="Password" title="Please enter the Password you registered here with." alt="Please enter the Password you registered here with."><p><p> <input type='submit' class="text_box" value='Login' title="Click here to log in." alt="Click here to log in."></form> <?php } else { ?> <?php $sql = mysql_query("SELECT * FROM `members` WHERE `username`='{$_COOKIE['ELv2']}' AND `site`=\"$Z\""); while($row = mysql_fetch_array($sql)) { $username = $row["username"]; } ?> <h2>Hello <?php echo $username; ?>!</h2> <div class="text_box" style="width: 160px"> If you are not <?php echo $username; ?>, please click <a href="logout.php">here</a>!<p> You have <?php echo $POINTS; ?> Eagle Gold on you! <br> <?php default: $query = "SELECT count(*) as msgs FROM `messages` WHERE `to` = '$u' AND status = 'unread' 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']} new messages"; $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!"; ?></div> <script type="text/javascript"> // Current Server Time script (SSI or PHP)- By JavaScriptKit.com (http://www.javascriptkit.com) // For this and over 400+ free scripts, visit JavaScript Kit- http://www.javascriptkit.com/ // This notice must stay intact for use. //Depending on whether your page supports SSI (.shtml) or PHP (.php), UNCOMMENT the line below your page supports and COMMENT the one it does not: //Default is that SSI method is uncommented, and PHP is commented: //var currenttime = '<!--#config timefmt="%B %d, %Y %H:%M:%S"--><!--#echo var="DATE_LOCAL" -->' //SSI method of getting server date var currenttime = '<? print date("F d, Y H:i:s", time())?>' //PHP method of getting server date ///////////Stop editting here///////////////////////////////// var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December") var serverdate=new Date(currenttime) function padlength(what){ var output=(what.toString().length==1)? "0"+what : what return output } function displaytime(){ serverdate.setSeconds(serverdate.getSeconds()+1) var datestring=montharray[serverdate.getMonth()]+" "+padlength(serverdate.getDate())+", "+serverdate.getFullYear() var timestring=padlength(serverdate.getHours())+":"+padlength(serverdate.getMinutes())+":"+padlength(serverdate.getSeconds()) document.getElementById("servertime").innerHTML=datestring+" "+timestring } window.onload=function(){ setInterval("displaytime()", 1000) } </script> <div align="center"> <span id="servertime" class="text_box" style="width: 160px" alt="LOOK!, a clock!" title="LOOK!, a clock!"></span> </div><br> <input type='button' value='Home' onClick='parent.location="index.php"' class='text_box' style='width: 170px' alt='Click here to go to the main page!' title='Click here to go to the main page!'><br> <input type='button' value='Mail!' onClick='parent.location="mail.php"' class='text_box' style='width: 170px' alt='Click here to read, send and manage your mail!' title='Click here to read, send and manage your mail!'><br> <input type='button' value='Forum!' onClick='parent.location="forum.php"' class='text_box' style='width: 170px' alt='Click here to view the mail!' title='Click here to view the forum!'><br> <input type='button' value='Logout!' onClick='parent.location="logout.php"' class='text_box' style='width: 170px' alt='Click here to log out!' title='Click here to log out!'><br> <?php $ch = mysql_num_rows(mysql_query("SELECT * FROM `members` WHERE `username`='{$_COOKIE['ELv2']}' AND `admin`='1'")); if($ch == 1) { ?> <input type='button' value='Manage site!' onClick='parent.location="managesite.php"' class='text_box' style='width: 170px' alt='Click here to manage the site!' title='Click here to manage the site!'> <?php } } ?> Quote Link to comment Share on other sites More sharing options...
MadTechie Posted May 5, 2008 Share Posted May 5, 2008 change <?php default: $query = "SELECT count(*) as msgs FROM `messages` WHERE `to` = '$u' AND status = 'unread' 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']} new messages"; $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!"; ?> to <?php $query = "SELECT count(*) as msgs FROM `messages` WHERE `to` = '{$_COOKIE['ELv2']}' AND status = 'unread' 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']} new messages"; ?> Quote Link to comment Share on other sites More sharing options...
eaglelegend Posted May 5, 2008 Author Share Posted May 5, 2008 Thanks for all the work, there IS something I didnt think about, but has just come to me, the email thing, how can I have it show as for example "mark@site.com" which it does., however, when user replys, if you look in the code you may see I TRIED to have it reply to the user's email address? could you check and work out how I can have it successfully have it do that? thanks! <?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 i'm not sure what your asking here if you want the option to send via site or email you could change <input type=\"hidden\" name=\"type\" value=\"2\" class=\"text_box\"> *theirs a few! to <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> Quote Link to comment Share on other sites More sharing options...
eaglelegend Posted May 5, 2008 Author Share Posted May 5, 2008 nope, thanks, but I already have that, however correctly, when you send an email you choose say, "mark@site.com" like it is meant to, however, I am wanting to have replys go to the users REAL email address, the email that the user registered with, and I WILL have a system where it validates users email address to besure no one is going to be usingmy online/offline features just to "spam" 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.