| | |
How to handle a member's site email, like email sent back and forth bwtween members?
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Mar 2007
Posts: 63
Reputation:
Solved Threads: 0
How to handle a member's site email, like email sent back and forth bwtween members?
0
#1 Nov 1st, 2008
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!
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.
Re: How to handle a member's site email, like email sent back and forth bwtween members?
0
#2 Nov 2nd, 2008
•
•
Join Date: Mar 2007
Posts: 63
Reputation:
Solved Threads: 0
Re: How to handle a member's site email, like email sent back and forth bwtween members?
0
#3 Nov 2nd, 2008
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...
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...
Re: How to handle a member's site email, like email sent back and forth bwtween members?
0
#4 Nov 2nd, 2008
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.
Re: How to handle a member's site email, like email sent back and forth bwtween members?
0
#5 Nov 2nd, 2008
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
table: PMs
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
In the inbox I'd use
In the outbox I'd use
table: users
PHP Syntax (Toggle Plain Text)
Column: description id: unique, auto increment id of user username: username password: hash of password email: users email address
PHP Syntax (Toggle Plain Text)
Column: description id: unique, auto increment id of message from: user id of who sent the message to: user id of who the message is to subject: message subject message: message content 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'" . ★ "If your not having fun, your doing something wrong." - Humbug
★ Did I help you out? Did I piss you off? Add to my reputation!
★ The Gabriel Method is a great book for losing weight and keeping healthy - I know Jon Gabriel Personally.
★ Did I help you out? Did I piss you off? Add to my reputation!
★ The Gabriel Method is a great book for losing weight and keeping healthy - I know Jon Gabriel Personally.
•
•
Join Date: Mar 2007
Posts: 63
Reputation:
Solved Threads: 0
Re: How to handle a member's site email, like email sent back and forth bwtween members?
0
#6 Nov 2nd, 2008
Re: How to handle a member's site email, like email sent back and forth bwtween members?
0
#7 Nov 2nd, 2008
•
•
•
•
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!
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)
#DROP TABLE IF EXISTS `inbox`; CREATE TABLE IF NOT EXISTS `inbox` ( `in_id` int(11) NOT NULL auto_increment, `in_mem_id` int(11) NOT NULL default '0', `in_mess_id` int(11) NOT NULL default '0', PRIMARY KEY (`in_id`) ); #DROP TABLE IF EXISTS `messages`; CREATE TABLE IF NOT EXISTS `messages` ( `mess_id` int(11) NOT NULL auto_increment, `mess_to` int(11) NOT NULL default '0', `mess_from` int(11) NOT NULL default '0', `mess_subject` varchar(200) NOT NULL default '', `mess_text` longtext NOT NULL, `unread` int(11) NOT NULL default '0', `time` int(11) NOT NULL default '0', PRIMARY KEY (`mess_id`) ); #DROP TABLE IF EXISTS `outbox`; CREATE TABLE IF NOT EXISTS `outbox` ( `out_id` int(11) NOT NULL auto_increment, `out_mem_id` int(11) NOT NULL default '0', `out_mess_id` int(11) NOT NULL default '0', PRIMARY KEY (`out_id`) );
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.
•
•
Join Date: Mar 2007
Posts: 63
Reputation:
Solved Threads: 0
Re: How to handle a member's site email, like email sent back and forth bwtween members?
0
#8 Nov 2nd, 2008
Re: How to handle a member's site email, like email sent back and forth bwtween members?
0
#9 Nov 2nd, 2008
instead of me trying to explain. check out this link: http://en.wikipedia.org/wiki/Cron
•
•
Join Date: Mar 2007
Posts: 63
Reputation:
Solved Threads: 0
Re: How to handle a member's site email, like email sent back and forth bwtween members?
0
#10 Nov 2nd, 2008
![]() |
Other Threads in the PHP Forum
- Previous Thread: using php to monitor and open com1 modem port
- Next Thread: Search problems
| Thread Tools | Search this Thread |
apache api array beginner binary body broken buttons cakephp checkbox class cms code cron curl database date date/time display dynamic ebooks echo email error file files folder form forms function functions global google href htaccess html image include insert ip javascript joomla limit link list login mail mediawiki menu mlm msqli_multi_query multiple mycodeisbad mysql number oop parameter paypal pdf php phpincludeissue problem query radio random recourse recursion regex remote script search seo server sessions sms source sp space speed sql static subdomain syntax system table tag tutorial update upload url validator variable vbulletin video web webdesign white wordpress xml youtube






