Question: Please Rewrite this code using the PHP mysqli real_escape_string() function:
Please Rewrite this code using the PHP mysqli real_escape_string() function:
$servername = "localhost";
$username = "me";
$password = "!myPa$$";
$dbname = "mydb";
if(isset($_POST["uname"], $_POST["upass"])) {
$conn = new mysqli($servername, $username, $password, $dbname);
if (!$conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$query = "select * from user where uname='$_POST[uname]' AND upass='$_POST[upass]'";
$result = $conn->query($query);
}
?>
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
