<?php
global $conn;
session_start();
include('db/db_connect.php');
include('inc/header.php');
?>
<div class="container">
<div class="row justify-content-center">
<?php
if(isset($_POST['login'])){
$username = $_POST['username'];
$password = md5($_POST['password']);
$sql = "select * from user_info where username = '$username' and passoword = '$password'";
$result = $conn->query($sql);
if( $result->num_rows > 0 ){
$row = $result->fetch_assoc();
$_SESSION['login'] = true;
$_SESSION['id'] = $row['user_id'];
$_SESSION['name'] = $row['username'];
header('location: addnumber.php');
} else{
echo '<div class="alert alert-warning" role="alert">Data Not Matched! </div>';
}
}
?>
<div class="col-md-6">
<h1 class="text-center mb-4">Login </h1>
<form action="" method="post">
<div class="mb-3">
<label for="username" class="form-label">username</label>
<input type="text" class="form-control" name ="username" id="username" placeholder="Enter user name">
</div>
<div class="mb-3">
<label for="password" class="form-label">Password</label>
<input type="password" name="password" class="form-control" id="password" placeholder="Enter your password">
</div>
<button type="submit" name="login" class="btn btn-primary">Login</button>
</form>
</div>
</div>
</div>
<?php
include('inc/footer.php');
?>