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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:51:38+00:00 2026-06-17T21:51:38+00:00

I am writing a search function that enables users to search a particular table

  • 0

I am writing a search function that enables users to search a particular table on my database. My website runs on CodeIgniter.

For the search function, I use $_GET instead of the CodeIgniter $this->input-get() since I had trouble using the latter within a helper function.

Now, here’s a security question:

What is the best way to sanitize and filter malicious characters in the $_GET array in order to prevent XSS and SQL injection?

Bearing in mind that data in the $_GET array will be used to query the database and retrieve info from it.

Is there a recursive way to clean the entire $_GET array without having to go thru one by one element?

Should I use PHP’s filter methods or CodeIgniter’s?

Any advice will be greatly appreciated!
Thanks in advance!

  • 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-17T21:51:40+00:00Added an answer on June 17, 2026 at 9:51 pm

    Codeigniter disables $_GET by default. Using the URI class you can simulate $_GET variables:

    GET parameters in the URL with CodeIgniter

    You can hack around it and use $_GET, which it sounds like you’ve done. But I wouldn’t recommend that. You should use CodeIgniter’s Input class. That provides XSS filtering and you can clean the entire $_GET array by running:

    $this->input->get(NULL, TRUE); // returns all GET items with XSS filter 
    

    If you use Codeigniter’s database utility class to run your queries, it has an escape function built in. Look at the Escaping Queries section.

    http://ellislab.com/codeigniter/user-guide/database/queries.html

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

Sidebar

Related Questions

I am writing a PHP/MYSQL search function which takes a users search query (as
I' writing a search function in C# SQL Server, my users can select multiple
I am having some difficulty writing a function that will search through a directory
Hoping this is just a case of syntax. I'm writing a custom search function
I'm writing an iterative function to search a binary tree for a certain value.
I am writing a little function to resize my search div to stay the
I'm writing a general search Stored Procedure to search in a table based on
Writing htaccess that allows me to remove index.php from the URL can confuse search
I'm sitting here writing a function that I'm positive has been written before, somewhere
I am writing a small script that will query a database for a title

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.