In my Login forms I hash username and password before I execute the queries
... class ...
private $username;
private $password;
protected function Login(){
$user = hash('sha256', $this->username);
$pass = hash('sha256', $this->password);
$this query = "..."
...
}
and in other kind of forms (like Search forms) I convert the strings to arrays and then I execute the queries, that way the query would look like this:
$searchstring = explode(' ', $search);
//.... Some lines of PHP code... and the resulting query is: ...
$this->query = "SELECT... WHERE name LIKE 'DELETE%' OR name LIKE 'FROM%' ";
$this->query.= " OR name LIKE 'USERS%' OR name LIKE 'WHERE%' OR name LIKE '1%'";
Is this enough to prevent sql injection? thanks