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

  • Home
  • SEARCH
  • 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 530835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:14:17+00:00 2026-05-13T09:14:17+00:00

I have one problem regarding the data insertion in PHP. In my site there

  • 0

I have one problem regarding the data insertion in PHP.

In my site there is a message system.

So when my inbox loads it gives one JavaScript alert.

I have searched a lot in my site and finally I found that someone have send me a message with the text below.

<script>
  alert(5)
</script>

So how can I restrict the script code being inserted in my database?

I am running on PHP.

  • 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-13T09:14:18+00:00Added an answer on May 13, 2026 at 9:14 am

    You should use strip_tags. If you still want to allow some HTML, then add a whitelist in the second parameter.

    I should add a really big caveat here. If you’re leaving any tags in a strip_tags whitelist, you can still be susceptible to javascript injection. Assume you’re allowing the seemingly innocuous tags <strong> and <em>:

    Strip tags will still allow all attributes, including event handlers
    like <strong onmouseover="window.href=http://mydodgysite.com">this</strong>.
    

    You have a couple of serious options:

    • strip_tags with no whitelist. Safe, but doesn’t allow for any formatting, and may cause problems with strings like this: "x<y, but y>4" --> "x4"
    • htmlentities. Use this when displaying the data on the screen (not on the data before you put it in the database). It’s safe, but doesn’t allow for formatting.
    • A different markup system than HTML, for example: Markdown, Wiki markup, BB Code. Requires rendering to convert back to HTML, but it’s mostly safe and can be quite flexible.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I often run into the problem that I have one stream full of data
I have one problem to work with NSMutableData . I defined one NSMutableData *receivedData
I have one interesting problem. I must parse mail body (regular expression), get some
One problem I have with open-source is not often the product or documentation, but
One problem that I come across regularly and yet don't have a solution to
I have a layout that is working, but it has one very annoying problem..
I have a webapp development problem that I've developed one solution for, but am
We have very strange problem, one of our applications is continually querying server by
The problem: I often have to update two or more repositories: One for the
Problem: I have two spreadsheets that each serve different purposes but contain one particular

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.