I'm making a website and I want to prevent SQL injections from happening. I have code that takes the POST data, makes a MYSQL query to check it. It then runs the mysqli_num_rows() function and then it does a password_verify().
Here is my code:
<?php
$Username = $_POST['Username'];
$Password = $_POST['Password'];
$Connect = mysqli_connect('localhost', 'user', 'pass', 'DB');
$sql = "SELECT * FROM table WHERE Username = '$Username'";
$output = mysqli_query($Connect, $sql);
if (mysqli_num_rows($output) > 0) {
while($row = mysqli_fetch_assoc($output)) {
if (password_verify($Password, $row['Password'])) {
$_SESSION = $row;
header('Location: Account.php');
} else {
echo 'Invalid Username or Password';
}
}
} else {
echo 'Invalid Username or Password';
}
?>
I was wondering if there is any way to bypass the password_verify() function with an SQL injection?
Thanks