Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    kjc
    kjc is offline
    New Coder
    Join Date
    Jun 2002
    Location
    England
    Posts
    56
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Inserting html tags into forms

    I am using PHP and a mysql database. When entering data into a text area in a form and then inserting into the database, I want html tags to automatically be inserted when for paragraphs that have been entered in a text box. Is there anyway of having the <P> inserted into the code. I presume JavaScript is used for this and not PHP.

    Also, does anyone know of any free resources for advanced form input(such as this one), where included is features for Bold and Italics etc?

    I am greatful for any help in this

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    paris, france
    Posts
    1,216
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i think it would be safer to use PHP for this. my friend once had this type of problem and used javascript and he ended up having a db full of crap cos the people had saved the page submitting the form and taken out the javascript
    photoshop too expensive? use the GIMP! www.gimp.org

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    The Planet Earth Code Poet: True
    Posts
    282
    Thanks
    0
    Thanked 1 Time in 1 Post
    PHP has a built in function to do this, nl2br(). I will move this thred to the PHP forum for further discussion.

  • #4
    kjc
    kjc is offline
    New Coder
    Join Date
    Jun 2002
    Location
    England
    Posts
    56
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by JohnKrutsch
    PHP has a built in function to do this, nl2br(). I will move this thred to the PHP forum for further discussion.
    Thats brilliant. Thank you John

  • #5
    New to the CF scene
    Join Date
    Jun 2002
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You could also do the following

    PHP Code:
    $something eregi_replace("\r\n","<br>",addslashes($something)); 
    Then you can place that variable when using the set command on your sql query. Use the br tag instead of the paragraph tag, it will double space your paragraphs otherwise. Hope ths helps.

  • #6
    Regular Coder
    Join Date
    May 2002
    Location
    London, England
    Posts
    367
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That is what nl2br() does
    Jeewhizz - MySQL Moderator
    http://www.sitehq.co.uk
    PHP and MySQL Hosting

  • #7
    Regular Coder
    Join Date
    Jun 2002
    Location
    Sheffield, UK
    Posts
    552
    Thanks
    0
    Thanked 0 Times in 0 Posts
    if you are going to be using the contents of the field in some form of JS then i recommend using ereg, nl2br() simply appends a <br> tag onto the end of every carriage return
    "To be successful in IT you don't need to know everything - just where to find it in under 30 seconds"

    (Me Me Me Me Me Me Me Me Me)


  •  

    Posting Permissions

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