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 8067219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:13:16+00:00 2026-06-05T12:13:16+00:00

Possible Duplicate: The ultimate clean/secure function After reading up on PHP security I have

  • 0

Possible Duplicate:
The ultimate clean/secure function

After reading up on PHP security I have the feeling that anything I code is always insecure. So to combat the security issues of user input I have created a function that allows me to escape and strip user input for any usage situation.

I would just like to know if this is in fact secure and if I could make it more secure. Also what kind of attacks would this prevent? From what I can tell XSS by using _GET, HTML input and MYSQL injection would have been prevented?

function _INPUT($name,$tag,$sql,$url)
{
if ($_SERVER['REQUEST_METHOD'] == 'GET')
    $filter = ($_GET[$name]);//Assign GET to filter variable

    if ($tag == true)//Remove all HTML, PHP and JAVASCRIPT tags
    {
        $filter = strip_tags($filter);
    }
    if ($sql == true)//If MYSQL escaping is enabled
    {
        $filter = mysql_real_escape_string($filter);
    }
    if ($url == true)//If URL encoding is enabled
    {
        $filter = urlencode($filter);
    }
    return $filter;     

}

$output = _INPUT('name',true,true,true);

I will be using prepared statements for MYSQL too, although I need to read up on them more to fully understand how it prevents injection.

Thank you for your time.

  • 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-06-05T12:13:17+00:00Added an answer on June 5, 2026 at 12:13 pm

    Once again, there is no universal escape function that just magically makes things “secure”.

    See this: https://stackoverflow.com/a/7810880/362536

    Different escape methods are used for different things. You can’t just run a bunch of data through a bunch of functions that are supposed to be used in specific contexts. You are creating garbage data, and are no more secure than you were with the raw user data in the first place.

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

Sidebar

Related Questions

Possible Duplicate: PHP: the ultimate clean/secure function I have got this code when I
Possible Duplicate: The ultimate clean/secure function I was informed in another thread that this
Possible Duplicate: PHP: the ultimate clean/secure function I am working on an experimental social
Possible Duplicate: The ultimate clean/secure function When it comes to sanitizing POST/GET data could
Possible Duplicate: How to call a JavaScript function from PHP? I have a php
Possible Duplicate: What is the ultimate postal code and zip regex? I need Regex
Possible Duplicate: Yield In VB.NET In C#, when writing a function that returns an
Possible Duplicate: PHP get all arguments as array? Within a javascript function arguments always
Possible Duplicate: How to successfully rewrite old mysql-php code with deprecated mysql_* functions? I
Possible Duplicate: What is the best PHP code encryptor? Encrypt php code How do

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.