<?php include 'header.php'; ?>
<h2>สมัครสมาชิก</h2>
<form action="regis.php" method="post">
    Username: <input type="text" name="username" required><br>
    Password: <input type="password" name="password" required><br>
    <button type="submit" name="regis_btn">สมัครเลย</button>
</form>

<?php
if(isset($_POST['regis_btn'])){
    include 'connect.php';
    $u = $_POST['username'];
    $p = $_POST['password']; // ควรใช้ password_hash ในงานจริง
    $sql = "INSERT INTO users (username, password) VALUES ('$u', '$p')";
    if($conn->query($sql)){
        echo "<script>alert('สมัครสำเร็จ!'); window.location='login.php';</script>";
    }
}
include 'footer.php';
?>