943,596 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 1232
  • PHP RSS
You are currently viewing page 1 of this multi-page discussion thread
Nov 1st, 2008
0

How to handle a member's site email, like email sent back and forth bwtween members?

Expand Post »
Hello, all: have this general question on how to handle member's email in a site...

what is the right way to setup an email-system structure, say like in dating site, where members can email between each other, and if a member receives a new email it will "show" new email, and once it is read, then it turns off... member would either receive email notices to their email, or coudl also login in the site to read their email... (like Yahoo too per say)

Not sure how the whole system would be setup... would the emails that are sent back and forth between members be entered into a database, which then will show in each member's email list as send/received email? and if so, how would the site know that an "email" has been read or not? and show appropriate "new" email warning? I am thinking, maybe a conditional statement like "if email present in users[email] field, show "new-mail" icon, else show-nothing"??

Or am I completely off base?

Any feedback much appreciated!
Last edited by websurfer; Nov 1st, 2008 at 11:54 pm.
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
websurfer is offline Offline
65 posts
since Mar 2007
Nov 2nd, 2008
0

Re: How to handle a member's site email, like email sent back and forth bwtween members?

actually a system like this is quite simple. i have created a few and i am working with one on my newest project.

i can share some of my code once i know how your system is set up so it will easily integrate into your site.
Last edited by kkeith29; Nov 2nd, 2008 at 1:26 am.
Reputation Points: 235
Solved Threads: 193
Nearly a Posting Virtuoso
kkeith29 is offline Offline
1,315 posts
since Jun 2007
Nov 2nd, 2008
0

Re: How to handle a member's site email, like email sent back and forth bwtween members?

Hi, Keith:

thanks for your reply..
What I was looking for was just a basic idea/framework on how one would go about setting something like this up.. I am trying to learn this language a bit better so wanted to just get basic direction, guidance on how something like is supposed to work so i can try to replicate it...
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
websurfer is offline Offline
65 posts
since Mar 2007
Nov 2nd, 2008
0

Re: How to handle a member's site email, like email sent back and forth bwtween members?

ok, well start by setting up a database. i used an inbox, outbox, and message table. after this is created, start making a members area where users need to login. this is so you can tell whos messages need to be displayed. upon completion of that make input forms like the "send message" feature. then make the message display pages.
Last edited by kkeith29; Nov 2nd, 2008 at 1:53 am.
Reputation Points: 235
Solved Threads: 193
Nearly a Posting Virtuoso
kkeith29 is offline Offline
1,315 posts
since Jun 2007
Nov 2nd, 2008
0

Re: How to handle a member's site email, like email sent back and forth bwtween members?

Personally, I would make a few tables like this: (I will refer to email's (eg someone@example.com) as emails and messages between users as Personal Messages (PM's)
table: users
PHP Syntax (Toggle Plain Text)
  1. Column: description
  2. id: unique, auto increment id of user
  3. username: username
  4. password: hash of password
  5. email: users email address
table: PMs
PHP Syntax (Toggle Plain Text)
  1. Column: description
  2. id: unique, auto increment id of message
  3. from: user id of who sent the message
  4. to: user id of who the message is to
  5. subject: message subject
  6. message: message content
  7. read: tinyint where 1 means "read" and 0 means unread

I always include an id and use that when referring to rows. On a page that isn't the users "inbox" I would use the query "SELECT `id` FROM `PMs` WHERE to='$user_id' AND read=0" then if a result was returned then you echo a link to their inbox.

In the inbox I'd use "SELECT * FROM `PMs` WHERE to='$user_id'" and the "read" column can be used to, say, display the messages as bold or not bold.

In the outbox I'd use "SELECT * FROM PMs WHERE from='$user_id'" .
Reputation Points: 20
Solved Threads: 13
Junior Poster in Training
humbug is offline Offline
93 posts
since Oct 2005
Nov 2nd, 2008
0

Re: How to handle a member's site email, like email sent back and forth bwtween members?

Thanks guys, one more question... I get much of what you are saying, but in the case of Humbug's suggestion. how is the "read" (tinyint) cloumn, suppsoed to indicate, or know to indicate that message has been read or not read? how would it become 0 or 1??

Thanks!
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
websurfer is offline Offline
65 posts
since Mar 2007
Nov 2nd, 2008
0

Re: How to handle a member's site email, like email sent back and forth bwtween members?

Click to Expand / Collapse  Quote originally posted by websurfer ...
Thanks guys, one more question... I get much of what you are saying, but in the case of Humbug's suggestion. how is the "read" (tinyint) cloumn, suppsoed to indicate, or know to indicate that message has been read or not read? how would it become 0 or 1??

Thanks!
once the member goes to the "view" portion of the code, have it mark the message as read if it is unread. pretty simple.

also, when i was creating my system, which was a lot like humbugs', i found a major flaw. once someone deletes the message from the database, it will delete the message from the senders outbox as well. this is why i used an inbox and outbox table. they both refer to an instance the message table, so you can't delete the message itself.

to fix this problem i used something like this:

PHP Syntax (Toggle Plain Text)
  1. #DROP TABLE IF EXISTS `inbox`;
  2. CREATE TABLE IF NOT EXISTS `inbox` (
  3. `in_id` int(11) NOT NULL auto_increment,
  4. `in_mem_id` int(11) NOT NULL default '0',
  5. `in_mess_id` int(11) NOT NULL default '0',
  6. PRIMARY KEY (`in_id`)
  7. );
  8. #DROP TABLE IF EXISTS `messages`;
  9. CREATE TABLE IF NOT EXISTS `messages` (
  10. `mess_id` int(11) NOT NULL auto_increment,
  11. `mess_to` int(11) NOT NULL default '0',
  12. `mess_from` int(11) NOT NULL default '0',
  13. `mess_subject` varchar(200) NOT NULL default '',
  14. `mess_text` longtext NOT NULL,
  15. `unread` int(11) NOT NULL default '0',
  16. `time` int(11) NOT NULL default '0',
  17. PRIMARY KEY (`mess_id`)
  18. );
  19. #DROP TABLE IF EXISTS `outbox`;
  20. CREATE TABLE IF NOT EXISTS `outbox` (
  21. `out_id` int(11) NOT NULL auto_increment,
  22. `out_mem_id` int(11) NOT NULL default '0',
  23. `out_mess_id` int(11) NOT NULL default '0',
  24. PRIMARY KEY (`out_id`)
  25. );

then to keep your database running smoothly, have cron job that will check if a message is not in a members inbox or outbox and if its not delete it.
Last edited by kkeith29; Nov 2nd, 2008 at 12:17 pm.
Reputation Points: 235
Solved Threads: 193
Nearly a Posting Virtuoso
kkeith29 is offline Offline
1,315 posts
since Jun 2007
Nov 2nd, 2008
0

Re: How to handle a member's site email, like email sent back and forth bwtween members?

thanks Keith, I think I got the basics of it. Thanks for your feedback.
One more quick question, what is a "cron" job??
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
websurfer is offline Offline
65 posts
since Mar 2007
Nov 2nd, 2008
0

Re: How to handle a member's site email, like email sent back and forth bwtween members?

instead of me trying to explain. check out this link: http://en.wikipedia.org/wiki/Cron
Reputation Points: 235
Solved Threads: 193
Nearly a Posting Virtuoso
kkeith29 is offline Offline
1,315 posts
since Jun 2007
Nov 2nd, 2008
0

Re: How to handle a member's site email, like email sent back and forth bwtween members?

thanks again... gonna check out link
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
websurfer is offline Offline
65 posts
since Mar 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: using php to monitor and open com1 modem port
Next Thread in PHP Forum Timeline: Search problems





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC