Private Messaging on Your Website
- Private Messaging on Your Website
- Private Message Login
- Private Message Logout
- Private Message Sending Form
- Send Private Message
- Private Message Inbox — Received Messages
- Private Message Outbox — Sent Messages
- Check Private Message Session ID
- Delete Received Private Message
- Delete Sent Private Message
This page is a tutorial on putting a private messaging (PM) system on your website. It uses sessions, input validation, PHP, MySQL, and a menu system. There are two main methods you can use. One is to have the word Messages in your navigation system and when you click on it, you are taken to the Private Message Login page. Here you login and go to the Private Message Sending Form where you can send a message or use the menu in the side bar to check out your inbox or outbox, or delete messages from your inbox or outbox. Another method is to require logging in to use your website, and the word Messages in your navigation system takes you to the Private Message Sending Form where you can send a message or use the menu in the side bar to check out your inbox or outbox, or delete messages from your inbox or outbox. The screenshot above is the private message inbox.
All kinds of sites use private messaging: bulletin board sites, bank sites, social networking sites, dating sites, forums, blogs, club sites—the list is endless. The point is to allow a kind of on-site email between users that know one or more other users' usernames. But there are no spam folders or Nigerian princess scams here. Instead, there are messages between users that know each other enough to have learned some user names. You can feel free to delete anything outgoing or incoming, and the user experience will be that these messages are gone forever. They're actually not, to the webmaster, who can easily find them in the MySQL database table. Here he can delete them, edit them, or whatever. Any sent message deleted in your outbox will of course stay in the recipient's inbox, and any received message deleted in your inbox will of course stay in the sender's outbox. But each user will fully control what she/he sees in her/his inbox and outbox. The Nigerian princesses will have to look for love or money (mostly money!) elsewhere, since they won't find out your user name so they cannot send you a PM in the first place. Our password system uses a nice hashing routine, by the way, so passwords are stored only as hashes that get both md5 and sha512 hashing before storage in your MySQL database table.
But what good will messaging do for you or your website? Like Wikipedia says, "Personal messages are more anonymous than regular e-mail messages because the e-mail address and IP address of the sender and recipient are not made available, except to administrators and sometimes moderators." Instant messaging (IM) is a form of real-time direct text-based communication between two or more people using personal computers or other devices, but personal messaging does not require those involved to be on the same website at the same time. Even with texting, communication does not require the communicators' simultaneous presense. This makes both personal messaging and texting usually less immediate but more realistic, since most people are NOT on the same sites (or concomitantly texting) at the same time. Personal messaging beats email because you cannot get mail from those who don't know your user name. This doesn't mean that spammers can't find a way to spam you or hackers can't find a way to hack you, but that's pretty much true about ANY site on the Internet—in some cases, even secure ones. But for the most part, there's little upside to hacking personal messaging systems because there's no money involved or account numbers to steal or identities to swipe. Why bother?
How do you send a private message on the new Facebook? Up toward the top right of the persons wall there is Send Message. Click on the words and it will open. Alternatively, click on the text bubble icon, and click Send New Message. Fill out the recipient and the message and click Send. Most Facebook messages are private, but not messages you post on someone's wall. On the other hand, to send chat messages on Facebook you click Inbox, then click Compose a new message. Whenever your comments to a Facebook friend are not appropriate for a wall post (all his profile visitors will see it), private messages are the right alternative. Personal/private messages let you exchange email-style communication on Facebook and similar websites. All Facebook users can send and receive private messages. Users get red flag alerts in the top left corner of their screens whenever they have new incoming messages.
On the other hand, how do you send a private message on the Private Messaging system we are giving you in this tutorial? Simple. After logging in to use your website, find the word Messages in your navigation system. This takes you to the Private Message Sending Form where you can send a message or use the menu in the side bar to check out your inbox or outbox, or delete messages from your inbox or outbox. When you send a message to a user, that user gets an email in his email program telling him he just got a new message on your website, and it gives the login link so he can conveniently check it out. In your inbox you can click a button next to each message to indicate you read it. If you later decide you need to "mark" the message for some reason, to make it easier to find when you attempt to access it later, you can reclick the button and now it will indicate you did not read it (it's a toggle switch). Note that with our PM system, you don't need to click somewhere in the inbox just to see the message. All messages are displayed along with who they are from, their subject, and their date—right there in the inbox. Feel free to delete any or all messages if your box gets too full.