internal mail

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
chris_s_22
Forum Commoner
Posts: 76
Joined: Wed Dec 31, 2008 2:05 pm

internal mail

Post by chris_s_22 »

im trying to create a internal mail message system.
though I keep running into problems can anyone point me in direction of a good tutorial or help me with mine?

so far i got my database.
a page that displays list of messages in brief
a page that displays list of messages sent in brief

now i want to be able to delete messages

This is code im using to display messages. i also added a form as i thought i need some kind of checkbox and somedata
to be passed then on the maildelete.php im struggling to figure out what i should be checking for and my query

Code: Select all

<?php 
include_once 'Connect.php'; //This starts session, connect to database and calls any functions needed
$usernameid = $_SESSION['id'];
    $query = ("SELECT * FROM mail WHERE messageto = '$usernameid' ");
    $result = mysql_query($query) or die ('failed query.');
    $exist = mysql_num_rows($result);  
    if($exist=='0')
    {
    echo"You have no mail";
    }
    else
    {   echo "<form action='maildelete.php' method='POST' name='delete'>";
        echo "<table border='1' cellspacing='1' cellpadding='1'>";
        echo "<tr><td></td><td>FROM</td><td>SUBJECT</td></tr>";
        while ($row = mysql_fetch_assoc($result)) 
        {     
        $messagefrom = $row["messagefrom"];
        $messagedate = $row["date"];
        $subjecttitle = $row["subjecttitle"];
        $message = $row["message"]; 
        echo "<tr><td><input name='checkdelete' type='checkbox' value='1'></td>";    
        echo "<td>$messagefrom</td>";
        echo "<td><div align='left'>$subjecttitle</div>";
        echo "$message - only want it to display 1st 50 characters...<br>";
        echo "<div align='right'>$messagedate</div></td></tr>";
        }
        echo "<tr><td><input type='submit' value='DELETE' name='submit'></td></tr></table></form>";
    }
?>
User avatar
Robert07
Forum Contributor
Posts: 113
Joined: Tue Jun 17, 2008 1:41 pm

Re: internal mail

Post by Robert07 »

Do you have a unique index for each mail message? If you are going to use a form you can echo the message id in a hidden parameter right before the submit button, so you know which message to delete in your delete script.
Post Reply