Regex to forbid the userinput of ",';()

Discussion in 'PHP' started by Kellerkind, Nov 5, 2007.

  1. #1
    I just put the finishing touches on a shopping cart script I wrote and want to make it more secure by validating the user input. I read a couple of articles and look for a way to check the user input via php for the following signs:

    ",';()

    I just don't get it right with preg_match and regular expressions to detect the use of those signs. Any help would be awesome! :)
     
    Kellerkind, Nov 5, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    
    if (preg_match('~["\',;\(\)]~', $text))
    {
        // Throw error
    }
    
    PHP:
    This should do it.
     
    nico_swd, Nov 5, 2007 IP
  3. Kellerkind

    Kellerkind Active Member

    Messages:
    160
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #3
    awesome thanks!
     
    Kellerkind, Nov 5, 2007 IP