<?php
require 'config.php';
if($_POST){
    $mobile = $_POST['mobile'];
    $mac = $_POST['mac'];
    $otp = rand(100000,999999);

    $stmt = $pdo->prepare("INSERT INTO users(mobile, mac, otp) VALUES(?,?,?)");
    $stmt->execute([$mobile, $mac, $otp]);

    header("Location: index.php");
    exit;
}
?>
<html>
<head>
<link rel="stylesheet" href="assets/css/bootstrap.min.css">
</head>
<body>
<div class="container mt-4">
<h2>Add User</h2>
<form method="post">
<div class="mb-3">
<label>Mobile / Email</label>
<input type="text" name="mobile" class="form-control" required>
</div>
<div class="mb-3">
<label>MAC Address</label>
<input type="text" name="mac" class="form-control" required>
</div>
<button class="btn btn-success">Add</button>
<a href="index.php" class="btn btn-secondary">Cancel</a>
</form>
</div>
</body>
</html>
