SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Mar 2009
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Lightbulb Private Messaging Suggestions

    I am creating a site that will allow users to interact with each other via private messages. It can look like a message board - but should only be viewed by the two people that are involved in the conversation. What is the best tool for this? Can anyone link me to some tutorials or api's?

  2. #2
    play of mind Ernie1's Avatar
    Join Date
    Sep 2005
    Posts
    1,252
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's an example:
    Code:
    CREATE TABLE IF NOT EXISTS `pm` (
      `id` int(11) NOT NULL auto_increment,
      `fm` varchar(12) default NULL,
      `to` varchar(12) default NULL,
      `sj` text,
      `bd` text,
      `date` datetime NOT NULL default '0000-00-00 00:00:00',
      `read` char(1) default NULL,
      PRIMARY KEY  (`id`)
    );
    php code
    PHP Code:
    <?php

    // for insert
    if (! empty($fm) && ! empty($to))
    {
        
    $request mysql_query("INSERT INTO pm SET fm='$fm', `to`='$to', sj='$sj', bd='$bd', date='$date', `read`='n'") or die(mysql_error());
    }

    // for reading
    $query mysql_query("SELECT id, fm, sj, bd, date FROM pm WHERE id=$id AND `to` ='" $_SESSION['login'] . "'") or die(mysql_error());

    // update the table, set the message as read
    mysql_query("UPDATE pm SET `read` = 'y' WHERE id=$id AND `to` ='" $_SESSION['login'] . "'") or die(mysql_error());
    // ...
    my mobile portal
    ghiris.ro

  3. #3
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Ernie, why abbreviate the field names so drastically?

    It's much more readable if you used:
    PHP Code:
    $query mysql_query("SELECT ID, From, Subject, Body, Date FROM PrivateMessages WHERE ID=$id AND To ='" $_SESSION['login'] . "'") or die(mysql_error()); 
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  4. #4
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Not sure if you want to use a very simple forum, but take a look at Vanilla, this permits 2 or more users to have conversations that only appear in each others version of the "thread".

    This means that these users are "posting" but their side conversations remain private, not sure if that is what you mean. It could be worth looking at if your aim is more than the requirement you posted.

    The default install is very stripped down, and you progressively add features if you need them.

    I like it.

  5. #5
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    Plano
    Posts
    643
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ernie, i'm gonna have to second jake's sentiments: i can't stand abbreviated identifiers. i understand it's personal preference, but i prefer all my variables to be self-documenting -- i feel this assists the readability beyond just myself. while writing code i typically refactor any given variable 2-3 times; as a variable's role adapts and becomes more apparent, i clarify its purpose by refactoring the variable.

    [offtopic]do you guys feel google wave replace the need for individual websites to code their own message systems? i'm hopeful that it will become fairly widespread and that all message systems will lead this route.[/offtopic]

  6. #6
    SitePoint Guru
    Join Date
    Jan 2005
    Location
    heaven
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by XtrEM3 View Post
    ernie, i'm gonna have to second jake's sentiments: i can't stand abbreviated identifiers. i understand it's personal preference, but i prefer all my variables to be self-documenting -- i feel this assists the readability beyond just myself. while writing code i typically refactor any given variable 2-3 times; as a variable's role adapts and becomes more apparent, i clarify its purpose by refactoring the variable.

    [offtopic]do you guys feel google wave replace the need for individual websites to code their own message systems? i'm hopeful that it will become fairly widespread and that all message systems will lead this route.[/offtopic]
    While I agree with you on your self-documenting remark I'm overly anal about visual symmetry of my code and tend to abbreviate database columns and form variables. A stupid reason, but it annoys me. And its a pain in the tush having to be creative names. I'm no fan over used camel-casing, hyphens and so on -- only when it comes to forms and database table columns... Pet peeves and such ._.
    Creativity knows no other restraint than the
    confines of a small mind.
    - Me
    Geekly Humor
    Oh baby! Check out the design patterns on that framework!


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •