How to search and find data from SQL database using PHP

In last post we learn how to delete data from sql database in this post i will show you how to find some data and verify that data from sql database using php.

So for this SQL select query is used and we select this time a user name and password to verify them. If the user name match with the name in database then this show an output that user verified.



<?php
include "conn.php";

$user = $_POST['user'];
$pass = $_POST['password'];


$sql = "select user,password from alogin where user='".$user."' and password='".$pass."';";
$result=$conn->query($sql);


if ($result->num_rows > 0) {
    echo "User Athenticate successfully";

} else {
    echo "Error: " . $sql . "<br>" . $conn->error;
}

$conn->close();
?>


Create-connection-with-sql-database-in-php

No comments

Powered by Blogger.