<?php
include "config.php";

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $pid = mysqli_real_escape_string($con, $_POST['pid']);
    $name = mysqli_real_escape_string($con, $_POST['name']);
    $email = mysqli_real_escape_string($con, $_POST['email']);
    $password = md5(mysqli_real_escape_string($con, $_POST['password']));

    $query = "INSERT INTO users (pid, name, email, password, au) 
              VALUES ('$pid', '$name', '$email', '$password', 0)";

    if (mysqli_query($con, $query)) {
         echo '<script>window.location.href = "users.php";</script>';
         exit();
    } else {
        echo "Error: " . mysqli_error($con);
    }
}
?>
