I\'ve read about SQL injection so I tried it with my site and of course it worked.. I know that the solution is parameterized queries and I also know that there are a lot of
use:
$userPass = mysqli_real_escape_string($mysqli,$_POST["password"]);
This block the '' or '=' thing thing :) where $mysqli is your connection string ofc.
Here you go
$stmt = mysqli_prepare($dbc, "SELECT * FROM users WHERE username = ? AND password = ?");
mysqli_stmt_bind_param($stmt, "s", $userName);
mysqli_stmt_bind_param($stmt, "s", $userPass);
mysqli_stmt_execute($stmt);
$row = mysqli_stmt_fetch($stmt);
Documentation
As side note i would reccomend to encrypt your password or better use hash for security, it's not good to store password as plain text