<?php
include("db.php");
session_start();
$error = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $userid = $_POST['username'];
    $pwd = $_POST['password'];
    
    $sql = "select * from user where Phone='$userid' and password='$pwd'";
    $result = mysqli_query($db, $sql);
    $row = mysqli_fetch_array($result, MYSQLI_ASSOC);
    $count = mysqli_num_rows($result);

    if ($count == 1) {
        $_SESSION['user'] = $userid;
        header("location: import-url.php");
    } else {
        echo '<script language="javascript">';
        echo 'alert("Phone or Password is Incorrect!!");';
        echo 'window.location.href="./";';
        echo '</script>';
    }
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, viewport-fit=cover">
<title>Login Page</title>
<link rel="icon" href="assets/icons/icon-72x72.png">
<link rel="apple-touch-icon" href="img/icons/icon-96x96.png">
<link rel="apple-touch-icon" sizes="152x152" href="img/icons/icon-152x152.png">
<link rel="apple-touch-icon" sizes="167x167" href="img/icons/icon-167x167.png">
<link rel="apple-touch-icon" sizes="180x180" href="img/icons/icon-180x180.png">
<link rel="manifest" href="manifest.json">
<style>
    html, body {
        margin: 0;
        padding: 0;
        font-family: Arial, sans-serif;
        background-color: #0078D7;
        overflow: hidden; /* Prevents scrolling */
        width: 100vw;
        height: 100vh;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    .login-container {
        background-color: white;
        width: 300px;
        padding: 20px;
        border-radius: 5px;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    }
    .login-header {
        background-color: #003B70;
        color: white;
        padding: 10px;
        text-align: left;
        border-radius: 5px 5px 0 0;
    }
    .login-header h2 {
        margin: 0;
        font-size: 14px;
    }
    .login-header p {
        margin: 5px 0 0;
        font-size: 12px;
        animation: blink 1s step-end infinite alternate; /* Blinking effect */
    }
    @keyframes blink {
        50% { opacity: 0; }
    }
    .form-group {
        margin: 15px 0;
    }
    .form-group label {
        display: block;
        font-size: 14px;
    }
    .form-group input,
    .form-group select {
        width: 100%;
        padding: 8px;
        box-sizing: border-box;
        border: 1px solid #ccc;
        border-radius: 3px;
        font-size: 14px;
    }
    .form-group input[type="checkbox"] {
        width: auto;
        margin-right: 5px;
    }
    .login-footer {
        text-align: center;
        margin-top: 10px;
    }
    .login-footer button {
        padding: 8px 16px;
        font-size: 14px;
        border: none;
        border-radius: 3px;
        cursor: pointer;
    }
    .login-footer button.sign-in {
        background-color: #0078D7;
        color: white;
    }
    .login-footer button.cancel {
        background-color: #f1f1f1;
        color: black;
        margin-right: 5px;
    }
    .footer-info {
        position: absolute;
        bottom: 0;
        width: 100%;
        background-color: #F1F1F1;
        color: #666;
        text-align: center;
        font-size: 12px;
        padding: 5px;
    }
</style>
<script>
    // Function to update date and time
    function updateDateTime() {
        const now = new Date();
        const options = { day: '2-digit', month: 'long', year: 'numeric' };
        const dateStr = now.toLocaleDateString('en-GB', options);
        
        const timeOptions = { hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: true };
        const timeStr = now.toLocaleTimeString('en-GB', timeOptions);

        document.getElementById("current-date").textContent = dateStr;
        document.getElementById("current-time").textContent = timeStr;
    }

    // Call updateDateTime every second
    setInterval(updateDateTime, 1000);
</script>
</head>
<body onload="updateDateTime()">
<div class="login-container">
    <div class="login-header">
        <h2 id="current-date"></h2>
        <p id="current-time"></p>
    </div>
    <form method="POST">
        <div class="form-group">
            <label for="userId">Phone Number</label>
            <input type="number" name="username" id="password"  autocomplete="off" required>
        </div>
        <div class="form-group">
            <label for="password">Password</label>
            <input type="password" name="password"  id="password" autocomplete="off" required>
        </div>
        <div class="login-footer">
            <button type="submit" class="sign-in">Sign in</button>
        </div>
    </form>
</div>
<div class="footer-info">
     Indo B2BT Admin Panel
</div>
</body>
</html>
