I'm not sure whether this question should go here or in the database section; it seems relevant to both.
I've been all over the internet, but can't find an answer to this question. I like to play an online game with other members of my clan. Our clan has recently decided that we want to open up our own league for any player to join. I'm the main coder in our clan for this site. I can do sessions, cookies, and whatnot, but I'm stumped on this one aspect:
My plan is to create a pseudo-forum, similar to phpbb and other forum layouts, but without many of the bells and whistles; only specific aspects that we're actually going to use. I know how to use PHP, I know how to use MySQL, and I know how to use both of them together. Therefore, communicating with a database is not a problem. However, I don't know how to go about making a method to save messages that users post so that they can be retrieved later. I've looked at how phpbb works, and have found that it seems to keep a record for each forum entry. However, the messages are always encoded to an MD5, which is not reversable. I mean, the forum has to keep the messages /somewhere/ while only using the MD5 to validate them before posting them on the forum pages.
What I /can/ do, is save each message posted as a super long entry in a database table, but that seems horribly inefficent, and since forums don't seem to use this tactic, there's got to be a better way. I mean, I can encode them using MD5, but then there's no way to de-code them for displaying them back on the forum. Gahh! Is there a better way of doing what I'm trying to do, without storing an entire message in one table cell in the database?
Obviously, I'm not asking for specific code, only an idea of how to save long messages without taking up a lot of space. Any ideas or suggestions are truly appreciated.
Storing a message
Moderator: General Moderators
-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
Re: Storing a message
Short answer: Use an existing smaller PHP forum codebase and customize it as required:
1. Vanilla
2. punBB
Long answer: Creating a simple forum is fairly simple.
You need at least two tables:
You probably need one for users too.
Basically the idea is to set parentid to ZERO which indicates a parent topic and all replies to that post would then have the PKID of the original topic as their parent ID.
You could take is one step further and implement a tree like structure using this relation as well but that requires recursion or advanced looping and state management -- which is a PITA and harder to read code.
Cheers
1. Vanilla
2. punBB
Long answer: Creating a simple forum is fairly simple.
You need at least two tables:
Code: Select all
forums:
pkid, name, description
forums_posts:
pkid, parentid, subject, contentBasically the idea is to set parentid to ZERO which indicates a parent topic and all replies to that post would then have the PKID of the original topic as their parent ID.
You could take is one step further and implement a tree like structure using this relation as well but that requires recursion or advanced looping and state management -- which is a PITA and harder to read code.
Cheers
Re: Storing a message
Thank you, Hockey, for your reply.
Are you saying, then, if I were to try making my own, would I paste the PHP variable that contains the message into the "content" column in the "forums_posts" table? That's what I seem to get from your suggestion. It's just, I can't find any such table that contains forum contents (the messages) directly pasted in them with forum layouts such as phpbb. That's why I'm confused.
Are you saying, then, if I were to try making my own, would I paste the PHP variable that contains the message into the "content" column in the "forums_posts" table? That's what I seem to get from your suggestion. It's just, I can't find any such table that contains forum contents (the messages) directly pasted in them with forum layouts such as phpbb. That's why I'm confused.
-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
Re: Storing a message
Well you wouldn't be pasting...you'd be sending POST data to the field. But yes, that is the idea.Are you saying, then, if I were to try making my own, would I paste the PHP variable that contains the message into the "content" column in the "forums_posts" table?
Don't feel alone cause so am IThat's why I'm confused.