bam2550 Posted April 14, 2008 Share Posted April 14, 2008 I made a Simple Login System. Now i want people to be able to privately communicate with one another (similar to a forum PM system). One thing i am not sure is how to store the message in MySQL and how to make sure the right person requests it from MySQL... I am not really sure how to go about this. Googling has not really helped :-\ If anyone could help me out, or atleast point me into the right direction that would be awesome! Thank you Quote Link to comment https://forums.phpfreaks.com/topic/100972-private-message-system/ Share on other sites More sharing options...
Caesar Posted April 14, 2008 Share Posted April 14, 2008 `private_messages` id (INT) | userid (INT) | author (INT) | time_stamp (INT) | message (TEXT) | ======================================================================================================== 1 2 5 1128793540 hey you... Would be a simplified way of doing it. Quote Link to comment https://forums.phpfreaks.com/topic/100972-private-message-system/#findComment-516380 Share on other sites More sharing options...
bam2550 Posted April 14, 2008 Author Share Posted April 14, 2008 I dont understand what you mean x.x I think i can easily put everything INTO the database... But having the right person request it is something i dont understand xD Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/100972-private-message-system/#findComment-516384 Share on other sites More sharing options...
keeB Posted April 14, 2008 Share Posted April 14, 2008 Look in to SQL Joins. Quote Link to comment https://forums.phpfreaks.com/topic/100972-private-message-system/#findComment-516386 Share on other sites More sharing options...
bam2550 Posted April 14, 2008 Author Share Posted April 14, 2008 This is what i have so far to send it! http://pastebin.com/m450e5cc9 So now i have the information stored into the db... How do i get it to Bobbyś inbox safely so Jane doesnt get it (theorotical names btw) Quote Link to comment https://forums.phpfreaks.com/topic/100972-private-message-system/#findComment-516393 Share on other sites More sharing options...
laffin Posted April 14, 2008 Share Posted April 14, 2008 depends on how advance the pm box should be the db shud be something like id integer // msg id from_user integer // author id to_user intger // reciepient id sent timestamp // when it was sent status enum // (new,read) msg text // the msg itself than to check a users msg, check i the to_user field. u can check the to_user field with the status field to show if they have new msgs waiting in their inbox etc etc etc Quote Link to comment https://forums.phpfreaks.com/topic/100972-private-message-system/#findComment-516396 Share on other sites More sharing options...
bam2550 Posted April 14, 2008 Author Share Posted April 14, 2008 Okay i think im going to play with this some more... This seems very hard.. Im going to look up some tutorials about MySQL. I am confused now. Thanks for all your help though. I think i might be able to get this soon enough. Quote Link to comment https://forums.phpfreaks.com/topic/100972-private-message-system/#findComment-516399 Share on other sites More sharing options...
laffin Posted April 14, 2008 Share Posted April 14, 2008 Just think of how the system shud work for u. user1 writes a message -> user2 recieves a msg from user1 so for the basics u need from_id to_id msg_text now u want to add more features. like the date is was sent. than maybe the status of the msg (unread/read) so user can have a notice on the index instead of checking the inbox everytime. maybe a mass mail system, or mail to a group of users etc etc etc. Just begin with the basics, and work up and add on to it Quote Link to comment https://forums.phpfreaks.com/topic/100972-private-message-system/#findComment-516413 Share on other sites More sharing options...
ohdang888 Posted April 14, 2008 Share Posted April 14, 2008 having the right person request it is easy.... it can all be done via the query... $id = mysql_real_escape_string($_SESSION['id']); SELECT * FROM `table` WHERE `to`='$id' Quote Link to comment https://forums.phpfreaks.com/topic/100972-private-message-system/#findComment-516418 Share on other sites More sharing options...
bam2550 Posted April 14, 2008 Author Share Posted April 14, 2008 okay well can someone tell me if i did this wrong? Because right now Inbox.php is returning with nothing, when i am pretty sure there should be. inbox.php - http://pastebin.com/m6ac59cc2 send.php - http://pastebin.com/m777b0025 usermsg.php - http://pastebin.com/m19e468cf Thanks Quote Link to comment https://forums.phpfreaks.com/topic/100972-private-message-system/#findComment-516419 Share on other sites More sharing options...
ohdang888 Posted April 14, 2008 Share Posted April 14, 2008 well where is the link to inbox.php also, you're making your error system to complicated... just use "or die(mysql_error());" after all the queires , connect, and db select Quote Link to comment https://forums.phpfreaks.com/topic/100972-private-message-system/#findComment-516420 Share on other sites More sharing options...
bam2550 Posted April 14, 2008 Author Share Posted April 14, 2008 sorry! inbox.php - http://pastebin.com/m6ac59cc2 send.php - http://pastebin.com/m777b0025 usermsg.php - http://pastebin.com/m19e468cf i ment inbox not index! hehe... Quote Link to comment https://forums.phpfreaks.com/topic/100972-private-message-system/#findComment-516421 Share on other sites More sharing options...
ohdang888 Posted April 14, 2008 Share Posted April 14, 2008 on your inbox.php, you never define what rows to take the info from, and you never included the session.php SELECT * FROM table WHERE from='$username' btw, you should use user id's for messages, not usernames i've fixied it a little for you.. http://pastebin.com/m4d43fd73 http://pastebin.com/m38716f35 Quote Link to comment https://forums.phpfreaks.com/topic/100972-private-message-system/#findComment-516422 Share on other sites More sharing options...
bam2550 Posted April 14, 2008 Author Share Posted April 14, 2008 you mean SELECT * FROM table WHERE to='$username' since if it is asking from = username then it will get all the things that you sent... that would be good for the sent box, but not for this one and that is all? i dont understand what you meant i didnt define from rows :\ Quote Link to comment https://forums.phpfreaks.com/topic/100972-private-message-system/#findComment-516425 Share on other sites More sharing options...
ohdang888 Posted April 14, 2008 Share Posted April 14, 2008 opps, my bad.. WHERE `to`='$username' "defined waht rows:" means that you never speficied what to look for... if you don't use a WHERE clause, then you'll grab everything in that table... Quote Link to comment https://forums.phpfreaks.com/topic/100972-private-message-system/#findComment-516428 Share on other sites More sharing options...
bam2550 Posted April 14, 2008 Author Share Posted April 14, 2008 ohkay thanks yeah. Now is that all of it? Ill try this one more time! Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /opt/lampp/htdocs/test/inbox.php on line 16 thats the error i get. Quote Link to comment https://forums.phpfreaks.com/topic/100972-private-message-system/#findComment-516429 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.