Jump to content

How to send messages (from one member to another) in a php community script.


strujillo

Recommended Posts

Ok so i kind of have a theory.

 

so i create a new database called messages

With the following columns

to

from

subject

message

 

Ok so when the person sends all this information to the database, how would the person he sent it to view it? im getting stuck here, Maybe if the 'username' and the 'to' match you can view those messages.

 

Thanks

Simple.

 

The recieving user visits a message page and page checks the user, and displays messages and the info about them

 

You can just do some basic things:

 

connect to database

select messages table where the receiving user matches the user visiting the page (you can use sessions here)

load them into an array (while ($var = mysql_fetch_array($sqlstatment) )

and display them within the while ( {echo $var[to] . " " . $var[ect]; }

 

Does that make enough sense?

SELECT * FROM messages WHERE to = '{$_SESSION['username']}'

 

Assuming you've cleaned the session username. You might also wish to include a "read" field to keep up with whether the user has read the message or not... perhaps false if they haven't read it or a timestamp if they have.. just thinking out loud :)

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.