<?php
error_reporting(E_ALL);
ini_set('display_errors',1);
session_start();

$conn = mysqli_connect("localhost",
"kolhapurair_clinic_user",
"Vijaynanda@88",
"kolhapurair_clinic_db");

if(!$conn){
 die("DB Error");
}

if(isset($_POST['login'])){

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

$q=mysqli_query($conn,
"SELECT * FROM admins
 WHERE username='$user'
 AND password='$pass'");

if(mysqli_num_rows($q)==1){
 $_SESSION['admin']=$user;
 header("Location: dashboard.php");
 exit();
}else{
 $error="Invalid Login";
}

}
?>

<!DOCTYPE html>
<html>
<head>
<title>Clinic Login</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="assets/style.css">
</head>

<body>
<br>
<form action="index.php" method="get">
    <button type="submit" class="btn btn-success">Go To Home</button>
</form>
<div class="container">

<h3>Clinic Login</h3>

<form method="post">

<input class="form-control"
 type="text"
 name="username"
 placeholder="Username"
 required>

<input class="form-control"
 type="password"
 name="password"
 placeholder="Password"
 required>

<button class="btn btn-success"
 name="login">Login</button>


<hr>

<div style="text-align:center;margin-top:20px;">

<h3>Scan to Book Appointment</h3>

<img 
src="https://api.qrserver.com/v1/create-qr-code/?size=250x250&data=https://kolhapurairport.com/clinic/appointment_form.php"
alt="Appointment QR Code">

<p>Scan this QR code to book appointment</p>

</div>
<?php if(isset($error)){ ?>
<p style="color:red"><?=$error?></p>
<?php } ?>

</form>

</div>

</body>
</html>
