prepare("INSERT INTO users (username, password, email) VALUES (:username, :password, :email)");
$query->bindParam(':username', $_POST['username']);
$query->bindParam(':password', $password);
$query->bindParam(':email', $_POST['email']);
if($query->execute()) {
echo '
Registration successful
';
$result = $conn->query("SELECT id, username, password FROM users WHERE username = '$_POST[username]'")->fetch();
$_SESSION['user_name'] = $result['username'];
$_SESSION['user_id'] = $result['id'];
} else {
echo 'Registration failed
';
}
header("Refresh: 2; URL={$config['urls']['base']}");
require_once(TEMPLATES_PATH . "/footer.php");
?>