<?php
$host= “localhost”;
$user= “username”;
$pass= “password”;
$dbname = “emp”;
// Create connection
$conn = new mysqli($host, $user, $pass, $dbname);
if ($conn->connect_error) {
die(“Connection failed: ” . $conn->connect_error);
}
$result = $conn->query(“SELECT * FROM user where id = 4”);
if ($result->num_rows > 0) {
$row = $result->fetch_assoc();
if($row[’username’]==’abc’ && $row[’password’]==’12345′)
echo ‘the username and password matched’;
else
echo ‘Sorry username or password is wrong’;
} else {
echo “0 results”;
}
$conn->close();
?>
Question and answer is powered by AnsPress.io