added testing directory

This commit is contained in:
benninghoven 2024-04-18 13:37:13 -07:00
parent 261eb0c193
commit 011f1d5066
3 changed files with 57 additions and 14 deletions

View file

@ -1,7 +1,8 @@
version: '3.8' version: '3.8'
services: services:
db: database:
container_name: database
image: mysql:8 image: mysql:8
command: --default-authentication-plugin=mysql_native_password command: --default-authentication-plugin=mysql_native_password
restart: always restart: always
@ -10,22 +11,11 @@ services:
ports: ports:
- "3306:3306" - "3306:3306"
volumes: volumes:
- mysql_data:/var/lib/mysql
- ./init.sql:/docker-entrypoint-initdb.d/init.sql - ./init.sql:/docker-entrypoint-initdb.d/init.sql
networks:
- docker-compose-network
adminer: adminer:
container_name: adminer
image: adminer image: adminer
restart: always restart: always
ports: ports:
- 8081:8080 - 8080:8080
networks:
- docker-compose-network
volumes:
mysql_data:
networks:
docker-compose-network:
driver: bridge

View file

@ -0,0 +1,23 @@
<?php
// Retrieve form data
$hostname = $_POST['hostname'];
$username = $_POST['username'];
$password = $_POST['password'];
$database = $_POST['database'];
// Attempt MySQL server connection
$conn = new mysqli($hostname, $username, $password, $database);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
// Close connection
$conn->close();
?>

View file

@ -0,0 +1,30 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PHP MySQL Database Connection</title>
</head>
<body>
<h2>PHP MySQL Database Connection</h2>
<form action="connect.php" method="post">
<label for="hostname">Hostname:</label>
<input type="text" id="hostname" name="hostname" required><br><br>
<label for="username">Username:</label>
<input type="text" id="username" name="username" required><br><br>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required><br><br>
<label for="database">Database:</label>
<input type="text" id="database" name="database" required><br><br>
<input type="submit" value="Connect">
</form>
</body>
</html>