Private Messaging {Messages}

Discussion in 'PHP' started by IGiveMoney, Aug 25, 2008.

  1. #1
    Ok, so I am not sure how to complete this the way I would like it.

    Basically creating a PM system. Got it all working properly, but
    the thing that I want to figure out is..

    Example:
    -----------
    If I type a message here

    and hit return

    then return again

    See the spacing!?



    I am presuming that it has to be done before the
    insert of the db.

    The field is set to longtext in the database.

    So what would be the best way to accomplish this?
     
    IGiveMoney, Aug 25, 2008 IP
  2. cornetofreak

    cornetofreak Peon

    Messages:
    170
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #2
    i think this is what you need

    <textarea name="textfield" cols="30" rows="6" id="textfield"></textarea>

    and when inserting it into the database try magic qouts and mysql_real_escape_string
     
    cornetofreak, Aug 25, 2008 IP
  3. AimHigher

    AimHigher Member

    Messages:
    40
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #3
    When you pull the message from the database to display you can call nl2br():

    
    <?
    $formatted_text = nl2br($message['text']);
    ?>
    
    Code (markup):
    http://uk2.php.net/manual/en/function.nl2br.php

    Or you can wrap the output in a pre html tag.

    
    <pre><?= $message_text; ?></pre>
    
    Code (markup):
    http://www.w3schools.com/TAGS/tag_pre.asp
     
    AimHigher, Aug 25, 2008 IP
  4. Xabber

    Xabber Active Member

    Messages:
    437
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    58
    #4
    You could also use a WYSIWYG ( What you see is what you get ) messagebox. Correct me if I'm wrong.
     
    Xabber, Aug 25, 2008 IP