-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
35 lines (29 loc) · 854 Bytes
/
Copy pathindex.php
File metadata and controls
35 lines (29 loc) · 854 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php //index.php just to see if everything works
$host = 'localhost';
$db = 'acc_db'; //name of the sql db
$user = 'user'; //name of sql db user that has perms to acces the db
$pass = 'passw0rd';) //password for the user
$charset = 'utf8mb4';
$dsn = "mysql:host=$host;dbname=$db;charset=$charset";
try {
$pdo = new PDO($dsn, $user, $pass);
echo "<h2>✅ Connected to MariaDB successfully!</h2>";
// Fetch users
$stmt = $pdo->query('SELECT * FROM users');
echo "<ul>";
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
echo "<li>ID: {$row['id']}, Username: {$row['username']}</li>";
}
echo "</ul>";
} catch (PDOException $e) {
echo "<h2>❌ Connection failed:</h2>";
echo $e->getMessage();
}
?>
<!DOCTYPE html>
<html lang="en">
<body>
<br><br>
<a href="login.php">Login page</a>
</body>
</html>