Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6136949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:40:00+00:00 2026-05-23T17:40:00+00:00

To prevent an xss attack, if I use a php regex to block strange

  • 0

To prevent an xss attack, if I use a php regex to block strange characters like '> or ; do I still need to use htmlspecialchars and htmlentities?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T17:40:01+00:00Added an answer on May 23, 2026 at 5:40 pm

    PDO does a very effective job of protecting your queries from XSS attacks. No need to worry about whether or not you remembered to protect your queries, because it is automatic. Several other frameworks support this feature as well.

    If I’m not using PDO because of a client requirement or the like, I will at the very least build into my connection class an automatic htmlspecialchars function so that I never forget to do it (though this is my least favorite option)

    As a UI guy, I always attack my security issues starting on the –front– end first. Proper and well-designed front-end validation can stop unintentional issues from even getting to the query in the first place, and they’re the most effective UI pattern for reporting problems to the user. Blocking elements such as < or ; makes sense in most fields, because they just don’t fit. You can’t rely on the front end solely, though, because a person could bypass it by turning off javascript. But, it’s a good first step and a great way to limit improper queries on heavily traffic-ed sites. My validation of choice for quick and effective front-end validation of fields is here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is htmlentities best solution to prevent XSS in PHP? Also I would like to
I like to prevent XSS on my project, i just use Erlang and nginx.
Is this code secure to prevent XSS attacks ?? <?php $string = <b>hello world!</b>;
I have a WYsIWYG editor in my coldfusion app and need to prevent XSS
I am using htmlspecialchars() function to prevent XSS attacks. I have doubt regarding what
I use Owasp Anti samy with Ebay policy file to prevent XSS attacks on
In PHP to filter inputs data I use functions htmlspecialchars and mysql_real_escape_string. Is there
I want to prevent XSS attacks in my web application. I found that HTML
To prevent SQL injection, is it necessary to use mysql_real_escape_string() , when magic_quotes_gpc is
I need to prevent Session Fixation , a particular type of session hijacking, in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.