Quantcast
Channel: CodeIgniter Forums - All Forums
Viewing all articles
Browse latest Browse all 14348

SQL Injection problem

$
0
0
I'm begginer with CodeIgniter and I stucked on problem with counting. 

I try to count records in my database using code below:

$count = $this->db->where(['title'=> $this->input->post('title'), 'name'=> $this->input->post('name')])->from("table")->count_all_results();

Then I check the query in development using code below:

echo $this->db->last_query();

Everything is ok, if I send data like title: test1 and name: test2:

SELECT COUNT(*) AS `numrows` FROM `table` WHERE `title` = 'test1' AND `name` = 'test2'

But if I send data similar to SQL Injection: test1 AND id = 1' it changes to: 

SELECT COUNT(*) AS `numrows` FROM `lawki` WHERE `opis` = 'test1 AND `id` = 1\'' AND `nazwisko` = 'test2'

How to prevent changing in this query id to `id` ? If I send data "test1 ANDY = 1' the query is without ` around id.

Viewing all articles
Browse latest Browse all 14348

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>