How to I handle apostrophes on a form via Php

Discussion in 'PHP' started by hexadesigns, Mar 9, 2011.

  1. #1
    Should be like wearing a gogles for the experts.

    I have a simple HTML form that is sending data to an email address via php. However if there are names like Neil'o Brien the php form fails. This is because of the apostrophe in the name.

    How do I handle this?
     
    hexadesigns, Mar 9, 2011 IP
  2. ferostive

    ferostive Active Member

    Messages:
    162
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #2
    the problem is in your php script . try to change ' to " .
    or just put your script it , i will try to find the problem .
     
    ferostive, Mar 9, 2011 IP
  3. mandark7

    mandark7 Peon

    Messages:
    65
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    mandark7, Mar 9, 2011 IP
  4. hexadesigns

    hexadesigns Peon

    Messages:
    350
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks guys. Seems like stripslashes will do the trick.
     
    hexadesigns, Mar 9, 2011 IP
  5. SedNaX

    SedNaX Active Member

    Messages:
    1,326
    Likes Received:
    59
    Best Answers:
    0
    Trophy Points:
    90
    #5
    If you do stripslashes you'll lose the apostrophe. You don't want that I guess.

    Use addslashes , this will give you Neil\'o. When you need to display the data, use stripslashes.
     
    SedNaX, Mar 9, 2011 IP