SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Wizard TWTCommish's Avatar
    Join Date
    Aug 1999
    Location
    Pittsburgh, PA, USA
    Posts
    3,910
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    I need to allow people to login, signup, etc, and add info to the site, but I can't let them add any odd characters into the form...ie, quotation marks, slashes, semicolons, etc.

    How can I get this to work correctly? I've tried htmlspecialchars, but that doesn't achieve what I'm looking for...addslashes and stripslashes don't seem to either - is it easier to simply use JavaScript? If so, can someone help me out with that?

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually it is probably easiest with regular expressions.
    //Just add all the characters you don't want inside the brackets
    if (eregi("[%*/^&#()$!]", $word)) {
    print "No special characters please";
    }
    else {
    print "Entry okay";
    }
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    SitePoint Wizard TWTCommish's Avatar
    Join Date
    Aug 1999
    Location
    Pittsburgh, PA, USA
    Posts
    3,910
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sounds good - which characters do I need to use to ensure that my SQL queries go through without a problem, though?

  4. #4
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well quotation marks are okay because you can use addslashes and stripslashes for those. I usually keep %&*^ out but you may want to do some testing as to what is breaking your sql
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  5. #5
    SitePoint Wizard TWTCommish's Avatar
    Join Date
    Aug 1999
    Location
    Pittsburgh, PA, USA
    Posts
    3,910
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Freddy - you da man Works like a charm, and required very little editing for direct use in my project.

    Tell your cat I said "hi"


Bookmarks

Posting Permissions

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