I am trying to access my html website on localhost with xampp. The php file is stored in htdocs long with the html file. However i still seem to be getting this error. My database name is check and table name is loginform.
<?php
$host="localhost";
$user="root";
$password="";
$dbname="check";
//create connection
$conn=mysqli_connect('$host', '$user', '$password', '$dbname');
//check connection
if (mysqli_connect_errno()) {
die('could not connect:'.mysqli_connect_error());
# code...
}
//accept values
if (isset($_POST['username'])) {
$uname=$_POST['username'];
$password=$_POST['password'];
$sql="select * from loginform where $uname='".$user."' AND $password='".$pass."' limit 1";
$result=mysqli_query($sql);
//check query
if (mysqli_num_rows($result)==1) {
echo "You have Successfully logged in";
exit();
}
else{
echo "Invalid credentials";
exit();
}
mysqli_close($conn);
}
LOGIN
Username:Password:
– Shruti May 27 '20 at 09:13