Jump to content

Saves Messages


Recommended Posts

Hi, i plan on adding a "saved msgs" page into my mailing system on my site; im just curious as to how do i go about this? im new to this so im unsure how it would work, would the "save button" update my "saved" value in my message field (in my database) to say 1, then my query on my saved page filter out messages by that "saved" column and then display them to the appropriate user?

thanks

Link to comment
https://forums.phpfreaks.com/topic/108020-saves-messages/
Share on other sites

hi, im just wondergin where would my INSERT query in here go? Im looking to insert my message data into a new table upon the user clicking the save button  ???

 

<?php
session_start();
$user = $_SESSION['kt_login_id'];

    //Are they logged in or not?
    if(!$user)
        {
        echo "<br><p>Blah blah you arent logged in and stuff, you should do that or something</p><br>";
        }
        
    else
        {
        //We need to grab the msg_id variable from the URL.
        $msg_id = $_REQUEST['msg_id'];
        
        //Get all of the information about the message with and id number of the one sent through the URL
        $view_msg = mysql_query("SELECT * FROM messages_test WHERE id = '$msg_id'");
        $msg = mysql_fetch_array($view_msg);
        
        $reciever = $msg['reciever'];
        $sender = $msg['sender'];
        $subject = $msg['subject'];
        $message = $msg['message'];
	$datetime = $msg['datetime'];
        
        //If the person who is supposed to recieve the message is the currently logged in user everything is good
        if($reciever == $user)
            {
            //The message was recieved, so lets update the message in the database so it wont show up in the sent page any more
            mysql_query("UPDATE messages_test SET recieved='1' WHERE id = '$msg_id'");
            
            //Lets get the private message count, to display for the user
            $sql = mysql_query ("SELECT pm_count FROM members WHERE member_id='$user'");
            $row = mysql_fetch_array ($sql);
            $pm_count = $row['pm_count'];
            
            //Calculate the percentage full
            $percent = $pm_count/'50';
            $percent = $percent * '100';
            
            //Now we will display the little navigation thing, the fullness of the inbox, then display message information stuff, like who its from, the subject, and the body
            ?>
  <center>
            <b>
            
            
            <table width="100%">
              <tr>
                <td width="94" valign="middle" class="message_header">From</td>
                <td colspan="3" valign="middle" class="message_rows"><a href = "<?php echo "../member_profile.php?member_id=$sender"; ?>" class="message_rows_subject"><?php echo $sender; ?>
                  <label></label>
                </a></td>
              </tr>
              <tr>
                <td width="94" valign="middle" class="message_header">Date</td>
                <td colspan="3" valign="middle" class="message_rows_subject"><?php echo $datetime; ?></td>
              </tr>
              
              <tr>
                <td width="94" valign="middle" class="message_header">Subject</td>
                <td colspan="3" valign="middle" class="message_rows_subject"><?php echo $subject; ?></td>
              </tr>
              
              <tr>    
                <td width="94" valign="top" class="message_header">Body</td>
                <td height="300" colspan="3" valign="top" class="message_rows"><?php echo $message; ?></td>
              </tr>
              <tr>
                <td width="75" valign="top"><form id="form1" name="form1" method="post" action="mail_reply.php?msg_id=<?php echo $msg_id; ?>">
                  <label>
                    <input type="submit" name="reply" id="reply" value="Reply" />
                  </label>
                </form></td>
                <td width="75" valign="top"><form id="form2" name="form2" method="post" action="">
                  <label>
                    <input type="submit" name="Save" id="Save" value="Save" />
                  </label>
                </form>                </td>
                <td width="75" valign="top"><form id="form3" name="form3" method="post" action="delete.php">
                <label>
                    <input type="submit" name="Delete" id="Delete" value="Delete" />
                  </label>
                </form>                </td>
                <td width="300" valign="top"> </td>
              </tr>
            </table>
</center>
            <?php
            }
        //Everything is not good, someone tried to look at somone else's private message
        else
            {
            ?>
            <p>You cannot view somebody else's messages!</p>
            <?php
            }
        }
    ?>

Link to comment
https://forums.phpfreaks.com/topic/108020-saves-messages/#findComment-554078
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.