Hi,
I put together a pm system a little while ago, like anjanesh said, the data is just inserted in to a db.
I assume you have a membership system .. If so just create a form with fields
to:, subject:, message.
post that data to a sql INSERT query:
Code: Select all
$sql = mysql_query("INSERT INTO pm (user_name, subject, message, sender, sent, new, date)
VALUES('$user_name', '$subject', '$message', '$sender', '1', '1', now())") or die (mysql_error());
$sql = mysql_query("INSERT INTO pm (user_name, subject, message, sender, sent, date)
VALUES('$user_name', '$subject', '$message', '$sender', '0', now())") or die (mysql_error());
I create 2 querys, one is the data for the senders "sent items" and the other for the recievers inbox.
Other fields were added as yu can see above so you can query the table for the correct data.
user_name so you can query WHERE user_name = '$user_name'
new: query whether it is new mail.
sent: to query and show the pm message in the senders sent items.
date: using now() to insert date & time so it can be called on to show dates pm messages were sent.
Then you create your other pages (querys) toi grab the inbox data, send data, and also add your delete etc etc functions.
I created 4 pages:
inbox.php = lists inbox pm messages
sent.php = same as inbox.php but lists sent pm messages
read.php = shows the pm message for reading (with reply and quote reply) links
pm_parse.php = All my functions (querys) to run the pm system.
SQL Dump I used:
Code: Select all
CREATE TABLE pm
(
id int(6) NOT NULL auto_increment,
user_name varchar(255) NOT NULL,
subject varchar(255) NOT NULL,
message varchar(255) NOT NULL,
sender varchar(255) NOT NULL,
sent varchar(255) NOT NULL,
new varchar(255) NOT NULL,
date datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (id)
) TYPE=MyISAM;
Im not a very good explainer, but there is some food for thought, should be enough to give u the basic concept ..
hth