Jump to content
xisto Community
Sign in to follow this  
itssami

Sending Messeges Over A Website.

Recommended Posts

i want to learn how members of a website can send messeges to each other using php since im learning it.okay i can write in more detail..that for example if users can register on a website , suppose there are some users on the website , and now i want to learn how they can send messeges to each other.suppose each user has a unique ID ... and for example if some one has send the messege to other member of website , then he can know that he has recieved a new messege..something like inbox on the website where all of his messeges can be stored...lets say same way like on these IPB forums or any phpbb forums ? of course i know that there are endless CMS and forums which i can install and do it but as i said i want to learn it. so if some one can tell about some idea or some tutorial about it or any URL guiding this.thanks alot.

Share this post


Link to post
Share on other sites

A simple approach would be to store the message in a database, along with the ID of who it was sent to, and then display it to the recipient the next time they log in. For example, Arthur sends a message to a user called 'Martha'. The script that checks the database for a user called 'Martha', and discovers that her ID is 53. It then stores the message in the database, along with the ID 53. Then once user 53 or 'Martha' logs in again, it simply displays the message on her screen (or informs her that a message has arrived). I wont' write out all the code for you, but it's certainly not difficult to do.

Share this post


Link to post
Share on other sites

I'm not an expert with databases so correct me if im wrong but dont they have a limit to the amount of characters that can be stored in one feild?If they do, which I think they do, I would store each message into a file with an auto genereated filename, maybe a number which is one more than the one before it. Then using php to protect that file, maybe by using a session to see if the user is authorised to veiw it. Then in a database alongside the member who RECEIVED the message have a feild for message number and store the file name/number in that feild. Then when a user logs in have the database check to see if there is a message and if there is use php to take the file name/number and open the file to display the contents to the receiver. For storing multiple messages you could delimit (SP?) the file names/numbers by using commas and have the php script seperate them all out, example "filenames: 123, 456, 789" php would seperate them into "filename:123 filename:456 and filename:789" This would allow users to 'save' more than one message. And when they want to read one of them the php file will take "123" add an extension "123.php" and then display it to them. I hope that makes sense.I think this could be better than using a database because there wouldnt be a limit on the amount of chaacters that a message can contain however it might not be as secure as a database but if you used some kind of authentification.The best thing for you to do would be to look up database and file functions in php and make your own decision. This was just an idea to spark a plan :angry:

Share this post


Link to post
Share on other sites

In MySQL, it depends on the data type. The maximum length of a VARCHAR type, for instance, is specified in the field's creation (eg. field_name VARCHAR(limit)), with an absolute peak of 255 characters in older versions of MySQL (<= 4x, I think). The TEXT type, however, has a much larger limit of 65,535 characters, and chances of a text-based message being that long is slim. There are other data types though; such as LONGTEXT, which has a limit of 4,294,967,295 characters (that's about 3.9-4GB of text).

Edited by Spectre (see edit history)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.