The following files exists in this folder. Click to view.
insertUser.php22 lines UTF-8 Unix (LF)
<?php
require_once "check_login.php";
require_once "database_connection.php";
$username = trim($_POST["username"] ?? "");
$password = trim($_POST["password"] ?? "");
if ($username === "" || $password === "") {
header("Location: addUser.php?mess=Tomma fält är inte tillåtna.");
exit;
}
$sql = "INSERT INTO user (username, password) VALUES (?, ?)";
$stmt = $conn->prepare($sql);
$stmt->bind_param("ss", $username, $password);
$stmt->execute();
$newId = $conn->insert_id;
header("Location: admin.php?mess=Användare skapad (id {$newId}).");
exit;