dean7 Posted July 8, 2009 Share Posted July 8, 2009 Hi all, i have a inbox and a send message script witch my friend helped me code but ive got a problem with it. <?PHP INCLUDE("dbconn.php"); $result1=MYSQL_QUERY("select * from users WHERE username='$username'") or DIE ("cant do it"); $row100 = MYSQL_FETCH_ARRAY($result1); ?> | <a href="mail.php?action=compose">Compose</a> | <a href="mail.php?action=inbox">Inbox</a> | <table cellpadding="1" cellspacing="1" height="300" width="450"> <tr><td align=center valign=top> <?PHP IF($action==compose) { ECHO "<form action=mail.php?action=compose2 method=post>"; ECHO "<table>"; ECHO "<tr><td>Subject:</td><td><input type=text name=subject size=20 value=$subject></td></tr>"; ECHO "<tr><td>To:</td><td><input type=text name=to size=20 value=$to></td></tr>"; ECHO "<tr><td>Message:</td><td><textarea rows=16 cols=45 name=message></text></td></tr>"; ECHO "<tr><td><button type=submit>Send Mail!</button></td></tr>"; ECHO "</table>"; ECHO "</form>"; } IF($action==compose2) { $subject or DIE("Subject Blank"); $message or DIE("Message Black"); $to or DIE("To blank"); $date = DATE(YmdHis); $create = "INSERT INTO mail (UserTo, UserFrom, Subject, Message, SentDate, status) VALUES ('$to','$username','$subject','$message','$date','unread')"; $create2 = MYSQL_QUERY($create) or DIE("A letter could not be sent to $to!"); ECHO("Message Sent to $to!"); } IF($action==inbox) { $result=MYSQL_QUERY("select * from mail where UserTo='$username' ORDER BY SentDate DESC") or DIE ("cant do it"); ECHO "<table cellpadding=2 cellspacing=1 width=500 valign=top>"; WHILE ($row=MYSQL_FETCH_ARRAY($result)) { ECHO "<tr><td width=30>Mail:</td><td><a href=mail.php?action=veiw&mail_id=$row[mail_id]>$row[subject]</a></td><td width=50> <a href=mail.php?action=delete&id=$row[mail_id]><center>Delete</a><br></td></tr>"; } ECHO "</table>"; } IF($action==veiw) { $result=MYSQL_QUERY("select * from mail where UserTo='$username' and mail_id=$mail_id") or DIE ("cant do it"); $row=MYSQL_FETCH_ARRAY($result); IF($row[userTo]==$username) { } ELSE { ECHO "<font face=verdana><b>This isn't your mail!"; EXIT; } $query="UPDATE mail SET status='read' WHERE UserTo='$username' AND mail_id='$row[mail_id]'"; $query or DIE("An error occurred resulting that this message has not been marked read."); ECHO "<table border = 1 bordercolor = black width = 50% align=center><tr><td>$row[subject]</td><td>$row[userFrom]</td></tr><tr><td colspan='2'>$row[Message]<br><a href=mail.php?action=compose&to=$row[userFrom]&subject=RE:$row[subject]>Reply</a></td></tr></table>"; $rs = MYSQL_QUERY("UPDATE mail SET status='read' WHERE mail_id='$mail_id'"); } IF($action==delete) { $query = MYSQL_QUERY("DELETE FROM mail WHERE mail_id='$id' LIMIT 1"); IF($query) { ECHO "<font face=verdana>Message Deleted.</font>"; } ELSE { ECHO "The message wasnt deleted."; } } ?> When you click on compose it is meant to show the send message form but when i click it it just shows a blank white page. Anyone got any ideas why? Thanks Link to comment https://forums.phpfreaks.com/topic/165255-inbox-help/ Share on other sites More sharing options...
cunoodle2 Posted July 8, 2009 Share Posted July 8, 2009 You are missing some quotes in there and also never properly setting the "$action" variable. Try this instead.. <?php IF($_GET['action'] == "compose") { Link to comment https://forums.phpfreaks.com/topic/165255-inbox-help/#findComment-871487 Share on other sites More sharing options...
dean7 Posted July 8, 2009 Author Share Posted July 8, 2009 You are missing some quotes in there and also never properly setting the "$action" variable. Try this instead.. <?php IF($_GET['action'] == "compose") { That worked to show the form but now i carnt see the submit button and in were you type the message its got some of the code of the inbox :S Link to comment https://forums.phpfreaks.com/topic/165255-inbox-help/#findComment-871493 Share on other sites More sharing options...
cunoodle2 Posted July 8, 2009 Share Posted July 8, 2009 View the source code on your page in the browser. What exactly does it say about the submit button? What code is in the "inbox" field? The more specific you are the faster this will get solved. Link to comment https://forums.phpfreaks.com/topic/165255-inbox-help/#findComment-871522 Share on other sites More sharing options...
Danny620 Posted July 8, 2009 Share Posted July 8, 2009 i can see how this would work because you pull the records from the db by '$username' but i cant see how it is defined in the script what you should do is create a login system which stores the username in a session the when it comes to showing the mail for the logined user simple session_start(); $userid = $_session['username']; then quary the db like q = ("select message, subject, time FROM message WHERE username = '$userid' ") Link to comment https://forums.phpfreaks.com/topic/165255-inbox-help/#findComment-871526 Share on other sites More sharing options...
pengu Posted July 8, 2009 Share Posted July 8, 2009 add it to the top of your code, because it submits on itself html is a bit blah but..<button type=submit>Send Mail!</button> $action = $_GET['action']; <input type='submit' name='submit' value='submit'> Link to comment https://forums.phpfreaks.com/topic/165255-inbox-help/#findComment-871556 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.