| Server IP : 173.209.174.21 / Your IP : 216.73.216.89 Web Server : Apache/2.4.58 (Ubuntu) System : Linux wcfs-server 6.8.0-124-generic #124-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 13:00:45 UTC 2026 x86_64 User : nodor ( 1000) PHP Version : 8.3.6 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/vendorset/Vendorapp/admin/ |
Upload File : |
<?php
include '../config.php';
$message = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$username = $_POST['username'] ?? '';
$password = $_POST['password'] ?? '';
if (!empty($username) && !empty($password)) {
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
$conn = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
if ($conn->connect_error) {
$message = "Database connection failed: " . $conn->connect_error;
} else {
$sql = "INSERT INTO admins (username, password_hash) VALUES (?, ?)";
$stmt = $conn->prepare($sql);
if (!$stmt) {
$message = "Statement preparation failed: " . $conn->error;
} else {
$stmt->bind_param("ss", $username, $hashed_password);
if ($stmt->execute()) {
$message = "Admin user added successfully!";
} else {
$message = "Execution failed: " . $stmt->error;
}
$stmt->close();
}
$conn->close();
}
} else {
$message = "Please fill in both fields.";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Add Admin User</title>
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&display=swap" rel="stylesheet">
<style>
body {
font-family: 'Roboto', sans-serif;
background-color: #f5f5f5;
color: #333;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
min-height: 100vh;
}
.main-container {
background-color: #fff;
padding: 30px;
border-radius: 10px;
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
width: 80%;
max-width: 800px;
}
h2 {
text-align: center;
color: #1E90FF;
margin-bottom: 20px;
}
.button-back {
display: inline-block;
padding: 10px 20px;
background-color: #1E90FF;
color: white;
text-decoration: none;
border-radius: 5px;
font-size: 14px;
font-weight: bold;
text-align: center;
transition: background-color 0.3s ease;
margin-bottom: 20px;
}
.button-back:hover {
background-color: #1C86EE;
}
table {
width: 100%;
margin-bottom: 20px;
border-collapse: collapse;
}
th, td {
padding: 10px;
text-align: left;
font-size: 14px;
}
th {
background-color: #1E90FF;
color: white;
}
td {
background-color: #f9f9f9;
}
tr:nth-child(even) {
background-color: #f1f1f1;
}
tr:hover {
background-color: #e2e2e2;
}
.submit button {
background-color: #1E90FF;
color: white;
border: none;
padding: 10px 20px;
border-radius: 5px;
font-size: 14px;
font-weight: bold;
cursor: pointer;
transition: background-color 0.3s ease;
}
.submit button:hover {
background-color: #1C86EE;
}
.notice {
padding: 10px;
border-radius: 5px;
margin-bottom: 20px;
font-size: 14px;
}
.notice-success {
background-color: #d4edda;
color: #155724;
border: 1px solid #c3e6cb;
}
.notice-error {
background-color: #f8d7da;
color: #721c24;
border: 1px solid #f5c6cb;
}
</style>
</head>
<body>
<div class="main-container">
<h2>Add Admin User</h2>
<!-- Back to Dashboard Button -->
<div>
<a href="../admin_dashboard.php" class="button-back">Back to Dashboard</a>
</div>
<!-- Display Success or Error Message -->
<?php if (!empty($message)): ?>
<div class="notice <?= strpos($message, 'success') !== false ? 'notice-success' : 'notice-error' ?>">
<?= htmlspecialchars($message) ?>
</div>
<?php endif; ?>
<!-- Add User Form -->
<form method="POST" action="add_user.php">
<table>
<tr>
<th><label for="username">Username:</label></th>
<td><input type="text" id="username" name="username" placeholder="Enter a username" required></td>
</tr>
<tr>
<th><label for="password">Password:</label></th>
<td><input type="password" id="password" name="password" placeholder="Enter a password" required></td>
</tr>
</table>
<div class="submit">
<button type="submit">Add User</button>
</div>
</form>
</div>
</body>
</html>