SQL injection, like { ' or 1=1# } can't seem to be avoided in Codeigniter.
In my Model:
$username= $this->input->post('username');
$password= $this->input->post('password');
$this->db->where('username', $username);
$this->db->where('password', $password);
$query = $this->db->get('users');
$num = $query->num_rows();
if ($num == 1)
{return 'Found.';}
I have read that using Active records, the input will be automatically escaped. If i input ' or 1=1# in my password, I will be granted access. I have tried: 1. Query binding, like: (making my adaptations to my query)
$qStr = "SELECT * FROM users WHERE id=?";
$q = $this->db->query($qStr, array($id);
2. not using Active Records, rather the PHP mysqli_real_escape_string() Function. 3. Manually escaping my input
$this->db->where('password', $this->db->escape($password));
4. XSS Filtering
every method, still grants me access to ma data if i input ' or 1=1# in my form.