Web Analytics Made Easy -
StatCounter Inserting html tags into forms - CodingForum

Announcement

Collapse
No announcement yet.

Inserting html tags into forms

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new 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
    Eternity

  • #2
    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

    Comment


    • #3
      PHP has a built in function to do this, nl2br(). I will move this thred to the PHP forum for further discussion.

      Comment


      • #4
        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
        Eternity

        Comment


        • #5
          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.

          Comment


          • #6
            That is what nl2br() does
            Jeewhizz - MySQL Moderator
            http://www.sitehq.co.uk
            PHP and MySQL Hosting

            Comment


            • #7
              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)

              Comment

              Working...
              X