Spaces:
Sleeping
Sleeping
Commit
·
5ff1306
1
Parent(s):
4643dd5
initial upload
Browse files- Dockerfile +16 -0
- app/config.php +21 -0
- app/css/form_styling.css +24 -0
- app/css/main.css +0 -0
- app/css/table_styling.css +51 -0
- app/editar.php +46 -0
- app/eliminar.php +46 -0
- app/form.php +37 -0
- app/index.php +72 -0
- app/member_added.php +87 -0
Dockerfile
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# FROM debian:12.6
|
2 |
+
# RUN apt update -y
|
3 |
+
# RUN apt upgrade -y
|
4 |
+
# RUN apt install -y php
|
5 |
+
|
6 |
+
# Add PHP-Apache base image
|
7 |
+
FROM php:8.0-apache
|
8 |
+
# Install your extensions to connect to MySQL and add mysqli
|
9 |
+
RUN docker-php-ext-install mysqli && docker-php-ext-enable mysqli
|
10 |
+
# Install pdo is you need to use PHP PDO
|
11 |
+
RUN docker-php-ext-install pdo pdo_mysql
|
12 |
+
|
13 |
+
RUN sed -i "s/Listen 80/Listen 7860/" /etc/apache2/ports.conf
|
14 |
+
|
15 |
+
COPY app /var/www/html
|
16 |
+
WORKDIR /var/www/html
|
app/config.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html>
|
3 |
+
<body>
|
4 |
+
<?php
|
5 |
+
// ini_set('display_errors', 1);
|
6 |
+
// ini_set('display_startup_errors', 1);
|
7 |
+
// error_reporting(E_ALL);
|
8 |
+
|
9 |
+
define('DB_NAME', $_ENV['DB_NAME']);
|
10 |
+
define('DB_USER', $_ENV['DB_USER']);
|
11 |
+
define('DB_PASSWORD1', $_ENV['DB_PASSWORD1']);
|
12 |
+
define('DB_HOST', $_ENV['DB_HOST']);
|
13 |
+
|
14 |
+
$conn = @mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD1, DB_NAME);
|
15 |
+
echo("<h1>DATA</h1>");
|
16 |
+
if (!$conn) {
|
17 |
+
die('Could not connect:' . mysqli_connect_error());
|
18 |
+
}
|
19 |
+
?>
|
20 |
+
</body>
|
21 |
+
</html>
|
app/css/form_styling.css
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
input[type=text], input[type=number], select {
|
2 |
+
width: 100%;
|
3 |
+
padding: 12px 20px;
|
4 |
+
margin: 8px 0;
|
5 |
+
display: inline-block;
|
6 |
+
border: 1px solid #ccc;
|
7 |
+
border-radius: 4px;
|
8 |
+
box-sizing: border-box;
|
9 |
+
}
|
10 |
+
|
11 |
+
input[type=submit] {
|
12 |
+
width: 100%;
|
13 |
+
background-color: #2ca089;
|
14 |
+
color: white;
|
15 |
+
padding: 14px 20px;
|
16 |
+
margin: 8px 0;
|
17 |
+
border: none;
|
18 |
+
border-radius: 4px;
|
19 |
+
cursor: pointer;
|
20 |
+
}
|
21 |
+
|
22 |
+
input[type=submit]:hover {
|
23 |
+
background-color: #2ca089;
|
24 |
+
}
|
app/css/main.css
ADDED
File without changes
|
app/css/table_styling.css
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
body {
|
2 |
+
background-color: #EEE;
|
3 |
+
}
|
4 |
+
|
5 |
+
#container {
|
6 |
+
width: 900px;
|
7 |
+
margin-left: auto;
|
8 |
+
margin-right: auto;
|
9 |
+
}
|
10 |
+
|
11 |
+
#header {
|
12 |
+
color: #2ca089;
|
13 |
+
text-align: center;
|
14 |
+
font-size: 2em;
|
15 |
+
}
|
16 |
+
|
17 |
+
/* links */
|
18 |
+
|
19 |
+
a:link, a:visited {
|
20 |
+
background-color: #2ca089;
|
21 |
+
color: white;
|
22 |
+
padding: 5px 12px;
|
23 |
+
text-align: center;
|
24 |
+
text-decoration: none;
|
25 |
+
display: inline-block;
|
26 |
+
}
|
27 |
+
|
28 |
+
a:hover, a:active {
|
29 |
+
background-color: #AFDCB1;
|
30 |
+
}
|
31 |
+
|
32 |
+
#btn_add {
|
33 |
+
padding: 5px 0px;
|
34 |
+
text-align: right;
|
35 |
+
}
|
36 |
+
|
37 |
+
table {
|
38 |
+
border-collapse: collapse;
|
39 |
+
width: 100%;
|
40 |
+
}
|
41 |
+
|
42 |
+
th, td {
|
43 |
+
text-align: left;
|
44 |
+
padding: 8px;
|
45 |
+
}
|
46 |
+
|
47 |
+
tr:nth-child(even){background-color: white; }
|
48 |
+
th {
|
49 |
+
background-color: #2ca089;
|
50 |
+
color: white;
|
51 |
+
}
|
app/editar.php
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
# conectarme a bd ($conn) para obtener datos del id en la url
|
3 |
+
require_once('config.php');
|
4 |
+
$sql = "SELECT MemberID, FirstName, LastName, Age, Gender, Relationship FROM FamilyMembers WHERE MemberID =" . $_GET['id'];
|
5 |
+
$response = @mysqli_query($conn, $sql);
|
6 |
+
|
7 |
+
# mostrar los datos para confirmar
|
8 |
+
if ($response){
|
9 |
+
echo '<table>
|
10 |
+
<tr>
|
11 |
+
<th>MemberID</th>
|
12 |
+
<th>FirstName</th>
|
13 |
+
<th>LastName</th>
|
14 |
+
<th>Age</th>
|
15 |
+
<th>Gender</th>
|
16 |
+
<th>Relationship</th>
|
17 |
+
<th>Editar</th>
|
18 |
+
<th>Eliminar</th>
|
19 |
+
</tr>';
|
20 |
+
|
21 |
+
while ($row = mysqli_fetch_array($response)){
|
22 |
+
echo '<tr>
|
23 |
+
<td>' . $row['MemberID'] .' </td>
|
24 |
+
<td>' . $row['FirstName'] .' </td>
|
25 |
+
<td>' . $row['LastName'] .' </td>
|
26 |
+
<td>' . $row['Age'] . '</td>
|
27 |
+
<td>' . $row['Gender'] . '</td>
|
28 |
+
<td>' . $row['Relationship'] . '</td>
|
29 |
+
|
30 |
+
<td><a href="editar.php?id='. $row['MemberID'] .'">Editar</a></td>
|
31 |
+
|
32 |
+
|
33 |
+
</tr>';
|
34 |
+
}
|
35 |
+
echo '</table>';
|
36 |
+
}
|
37 |
+
|
38 |
+
else{
|
39 |
+
echo
|
40 |
+
"Cound not get a response from database " .
|
41 |
+
mysqli_error($conn);
|
42 |
+
}
|
43 |
+
|
44 |
+
mysqli_close($conn);
|
45 |
+
# borrar datos usando un boton
|
46 |
+
# Enviar una consulta a bd usando $conn
|
app/eliminar.php
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
# conectarme a bd ($conn) para obtener datos del id en la url
|
3 |
+
require_once('config.php');
|
4 |
+
$sql = "SELECT MemberID, FirstName, LastName, Age, Gender, Relationship FROM FamilyMembers WHERE MemberID =" . $_GET['id'];
|
5 |
+
$response = @mysqli_query($conn, $sql);
|
6 |
+
|
7 |
+
# mostrar los datos para confirmar
|
8 |
+
if ($response){
|
9 |
+
echo '<table>
|
10 |
+
<tr>
|
11 |
+
<th>MemberID</th>
|
12 |
+
<th>FirstName</th>
|
13 |
+
<th>LastName</th>
|
14 |
+
<th>Age</th>
|
15 |
+
<th>Gender</th>
|
16 |
+
<th>Relationship</th>
|
17 |
+
<th>Editar</th>
|
18 |
+
<th>Eliminar</th>
|
19 |
+
</tr>';
|
20 |
+
|
21 |
+
while ($row = mysqli_fetch_array($response)){
|
22 |
+
echo '<tr>
|
23 |
+
<td>' . $row['MemberID'] .' </td>
|
24 |
+
<td>' . $row['FirstName'] .' </td>
|
25 |
+
<td>' . $row['LastName'] .' </td>
|
26 |
+
<td>' . $row['Age'] . '</td>
|
27 |
+
<td>' . $row['Gender'] . '</td>
|
28 |
+
<td>' . $row['Relationship'] . '</td>
|
29 |
+
<td><a href="eliminar.php?id='. $row['MemberID'] .'">Eliminar</a></td>
|
30 |
+
|
31 |
+
|
32 |
+
</tr>';
|
33 |
+
}
|
34 |
+
echo '</table>';
|
35 |
+
}
|
36 |
+
|
37 |
+
else{
|
38 |
+
echo
|
39 |
+
"Cound not get a response from database " .
|
40 |
+
mysqli_error($conn);
|
41 |
+
}
|
42 |
+
|
43 |
+
mysqli_close($conn);
|
44 |
+
# borrar datos usando un boton
|
45 |
+
# Enviar una consulta a bd usando $conn
|
46 |
+
#
|
app/form.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html>
|
3 |
+
<head>
|
4 |
+
<link rel="stylesheet" type="text/css" href="css/main.css">
|
5 |
+
<link rel="stylesheet" type="text/css" href="css/form_styling.css">
|
6 |
+
</head>
|
7 |
+
<body>
|
8 |
+
<div id="container">
|
9 |
+
<div id=content>
|
10 |
+
<div id="interno">
|
11 |
+
<form action="member_added.php" method="post">
|
12 |
+
<div id="header">
|
13 |
+
<h3>Add Family Member</h3>
|
14 |
+
</div>
|
15 |
+
<div id="btn_add">
|
16 |
+
<a href="index.php">View Members</a>
|
17 |
+
</div>
|
18 |
+
<label for="fname">First Name</label>
|
19 |
+
<input type="text" id="first_name" name="first_name" maxlength="80">
|
20 |
+
<label for="lname">Last Name</label>
|
21 |
+
<input type="text" id="last_name" name="last_name" maxlength="80">
|
22 |
+
<label for="age">Age</label>
|
23 |
+
<input type="number" id="age" name="age" min="1" max="100">
|
24 |
+
<label for="gender">Gender</label>
|
25 |
+
<select id="gender" name="gender">
|
26 |
+
<option value="Male">Male</option>
|
27 |
+
<option value="Female">Female</option>
|
28 |
+
</select>
|
29 |
+
<label for="relationship">Relationship</label>
|
30 |
+
<input type="text" id="relationship" name="relationship" maxlength="80">
|
31 |
+
<input type="submit" name="submit" value="ADD">
|
32 |
+
</form>
|
33 |
+
</div>
|
34 |
+
</div>
|
35 |
+
</div>
|
36 |
+
</body>
|
37 |
+
</html>
|
app/index.php
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<DOCTYPE html>
|
2 |
+
<html>
|
3 |
+
<head>
|
4 |
+
<link rel="stylesheet" type="text/css" href="css/main.css">
|
5 |
+
<link rel="stylesheet" type="text/css" href="css/table_styling.css">
|
6 |
+
</head>
|
7 |
+
|
8 |
+
<body>
|
9 |
+
|
10 |
+
<div id="container">
|
11 |
+
<div id="header">
|
12 |
+
<h2>My Family</h2>
|
13 |
+
</div>
|
14 |
+
|
15 |
+
<div id="btn_add">
|
16 |
+
<a href="form.php">ADD</a>
|
17 |
+
</div>
|
18 |
+
|
19 |
+
<div id=“content”>
|
20 |
+
|
21 |
+
<?php
|
22 |
+
|
23 |
+
// ini_set('display_errors', 1);
|
24 |
+
// ini_set('display_startup_errors', 1);
|
25 |
+
// error_reporting(E_ALL);
|
26 |
+
|
27 |
+
require_once('config.php');
|
28 |
+
$sql = "SELECT MemberID, FirstName, LastName, Age, Gender, Relationship FROM FamilyMembers";
|
29 |
+
$response = @mysqli_query($conn, $sql);
|
30 |
+
|
31 |
+
if ($response){
|
32 |
+
echo '<table>
|
33 |
+
<tr>
|
34 |
+
<th>MemberID</th>
|
35 |
+
<th>FirstName</th>
|
36 |
+
<th>LastName</th>
|
37 |
+
<th>Age</th>
|
38 |
+
<th>Gender</th>
|
39 |
+
<th>Relationship</th>
|
40 |
+
<th>Editar</th>
|
41 |
+
<th>Eliminar</th>
|
42 |
+
</tr>';
|
43 |
+
|
44 |
+
while ($row = mysqli_fetch_array($response)){
|
45 |
+
echo '<tr>
|
46 |
+
<td>' . $row['MemberID'] .' </td>
|
47 |
+
<td>' . $row['FirstName'] .' </td>
|
48 |
+
<td>' . $row['LastName'] .' </td>
|
49 |
+
<td>' . $row['Age'] . '</td>
|
50 |
+
<td>' . $row['Gender'] . '</td>
|
51 |
+
<td>' . $row['Relationship'] . '</td>
|
52 |
+
<td><a href="editar.php?id='. $row['MemberID'] .'">Editar</a></td>
|
53 |
+
<td><a href="eliminar.php?id='. $row['MemberID'] .'">Eliminar</a></td>
|
54 |
+
|
55 |
+
|
56 |
+
</tr>';
|
57 |
+
}
|
58 |
+
echo '</table>';
|
59 |
+
}
|
60 |
+
|
61 |
+
else{
|
62 |
+
echo
|
63 |
+
"Cound not get a response from database " .
|
64 |
+
mysqli_error($conn);
|
65 |
+
}
|
66 |
+
|
67 |
+
mysqli_close($conn);
|
68 |
+
?>
|
69 |
+
</div>
|
70 |
+
</div>
|
71 |
+
</body>
|
72 |
+
</html>
|
app/member_added.php
ADDED
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html>
|
3 |
+
<head>
|
4 |
+
<link rel="stylesheet" type="text/css" href="css/main.css">
|
5 |
+
<link rel="stylesheet" type="text/css" href="css/form_styling.css">
|
6 |
+
</head>
|
7 |
+
<body>
|
8 |
+
<div id="container">
|
9 |
+
<div id="content">
|
10 |
+
<?php
|
11 |
+
require_once('config.php');
|
12 |
+
if(isset($_POST['submit'])) {
|
13 |
+
$null_fields = array();
|
14 |
+
if (empty($_POST['first_name'])) {
|
15 |
+
$null_fields[] = 'First Name';
|
16 |
+
} else {
|
17 |
+
$first_name = trim($_POST['first_name']);
|
18 |
+
}
|
19 |
+
if (empty($_POST['last_name'])) {
|
20 |
+
$null_fields[] = 'Last Name';
|
21 |
+
} else {
|
22 |
+
$last_name = trim($_POST['last_name']);
|
23 |
+
}
|
24 |
+
if (empty($_POST['age'])) {
|
25 |
+
$null_fields[] = 'Age';
|
26 |
+
} else {
|
27 |
+
$age = $_POST['age'];
|
28 |
+
}
|
29 |
+
if (empty($_POST['gender'])) {
|
30 |
+
$null_fields[] = 'Gender';
|
31 |
+
} else {
|
32 |
+
$gender = $_POST['gender'];
|
33 |
+
}
|
34 |
+
if (empty($_POST['relationship'])) {
|
35 |
+
$null_fields[] = 'Reliationship';
|
36 |
+
} else {
|
37 |
+
$relationship = $_POST['relationship'];
|
38 |
+
}
|
39 |
+
if (empty($null_fields)) {
|
40 |
+
$null_variable = "NULL";
|
41 |
+
$sql = "INSERT INTO FamilyMembers VALUES ($null_variable, '$first_name',
|
42 |
+
'$last_name', '$age', '$gender',
|
43 |
+
'$relationship')";
|
44 |
+
if (!mysqli_query($conn, $sql)) {
|
45 |
+
die ('Error: ' .
|
46 |
+
mysqli_error($conn));
|
47 |
+
}
|
48 |
+
echo "Family member has been entered!";
|
49 |
+
mysqli_close($conn);
|
50 |
+
}
|
51 |
+
else {
|
52 |
+
echo "You need to enter the follwing
|
53 |
+
missing data: <br />";
|
54 |
+
foreach ($null_fields as $null_field) {
|
55 |
+
echo $null_field . "<br />";
|
56 |
+
}
|
57 |
+
}
|
58 |
+
}
|
59 |
+
?>
|
60 |
+
<div id="form1">
|
61 |
+
<form action="member_added.php" method="post">
|
62 |
+
<div id="header">
|
63 |
+
<h3>Add Family Member</h3>
|
64 |
+
</div>
|
65 |
+
<div id="btn_add">
|
66 |
+
<a href="index.php">View Members</a>
|
67 |
+
</div>
|
68 |
+
<label for="fname">First Name</label>
|
69 |
+
<input type="text" id="first_name" name="first_name" maxlength="80">
|
70 |
+
<label for="lname">Last Name</label>
|
71 |
+
<input type="text" id="last_name" name="last_name" maxlength="80">
|
72 |
+
<label for="age">Age</label>
|
73 |
+
<input type="number" id="age" name="age" min="1" max="100">
|
74 |
+
<label for="gender">Gender</label>
|
75 |
+
<select id="gender" name="gender">
|
76 |
+
<option value="Male">Male</option>
|
77 |
+
<option value="Female">Female</option>
|
78 |
+
</select>
|
79 |
+
<label for="relationship">Relationship</label>
|
80 |
+
<input type="text" id="relationship" name="relationship" maxlength="80">
|
81 |
+
<input type="submit" name="submit" value="ADD">
|
82 |
+
</form>
|
83 |
+
</div>
|
84 |
+
</div>
|
85 |
+
</div>
|
86 |
+
</body>
|
87 |
+
</html>
|