<?php include '../includes/auth.php'; ?>
<?php include '../includes/db.php'; ?>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
  $username = $_POST['username'];
  $password = md5($_POST['password']);
  $role = $_POST['role'];
  $conn->query("INSERT INTO users (username, password, role) VALUES ('$username', '$password', '$role')");
  header("Location: users.php");
}
?>

<!DOCTYPE html>
<html lang="fa">
<head>
<meta charset="UTF-8">
<title>افزودن کاربر</title>
<link rel="stylesheet" href="../assets/css/style.css">
</head>
<body>
<h2>افزودن کاربر جدید</h2>
<form method="post">
  <input type="text" name="username" placeholder="نام کاربری" required><br>
  <input type="password" name="password" placeholder="رمز عبور" required><br>
  <select name="role">
    <option value="user">کاربر</option>
    <option value="admin">مدیر</option>
  </select><br>
  <button type="submit">افزودن</button>
</form>
</body>
</html>
