22 lines
541 B
PHP
22 lines
541 B
PHP
<?php
|
|
include_once 'database.php';
|
|
|
|
session_start();
|
|
|
|
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
|
$username = $_POST["username"];
|
|
$email = $_POST["email"];
|
|
$password = $_POST["password"];
|
|
|
|
$result = registerUser($username, $email, $password);
|
|
if ($result) {
|
|
$_SESSION['error_message'] = null;
|
|
$_SESSION['username'] = $username;
|
|
$_SESSION['email'] = $email;
|
|
} else {
|
|
$_SESSION['error_message'] = "User with this username already exists!";
|
|
}
|
|
header("Location: /products");
|
|
}
|
|
?>
|