<?php
session_start();
include('../config/db.php');

if($_SESSION['role'] != 'admin'){
    die("Akses ditolak!");
}

if(isset($_POST['submit'])){
    $email = $_POST['email'];
    $password = md5($_POST['password']);
    $license = $_POST['license'];
    $expired = $_POST['expired'];

    $conn->query("INSERT INTO users (email,password,license_key,expired_date)
    VALUES ('$email','$password','$license','$expired')");

    echo "User berhasil dibuat <a href='index.php'>Kembali</a>";
}
?>

<form method="post">
<h3>Tambah User</h3>
Email: <input type="email" name="email"><br>
Password: <input type="text" name="password"><br>
License: <input type="text" name="license"><br>
Expired: <input type="date" name="expired"><br>
<button name="submit">Simpan</button>
</form>