Skip to content

Commit 82072bd

Browse files
committed
initial commit
1 parent 7aadff6 commit 82072bd

File tree

13 files changed

+227
-0
lines changed

13 files changed

+227
-0
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
./db.sql
2+
./.gitignore

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
./env/mysql.env

db.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CREATE TABLE `issuetrackdb`.`tbl_registration` (`id` INT NOT NULL AUTO_INCREMENT , `db_email` VARCHAR(255) NOT NULL , `db_password` VARCHAR(255) NOT NULL , `db_passwordconf` VARCHAR(255) NOT NULL , PRIMARY KEY (`id`), UNIQUE (`db_email`)) ENGINE = InnoDB;

docker-compose.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
version: '3'
2+
3+
services:
4+
web:
5+
build: ./frontend
6+
ports:
7+
- "8000:80"
8+
stdin_open: true
9+
tty: true
10+
env_file:
11+
- ./env/mysql.env
12+
13+
db:
14+
image: mysql:latest
15+
container_name: webappdb
16+
restart: always
17+
volumes:
18+
- /home/fikradev/dbvolume:/home/app
19+
env_file:
20+
- ./env/mysql.env
21+
22+
monitor:
23+
image: phpmyadmin
24+
restart: always
25+
ports:
26+
- 8080:80
27+
environment:
28+
- PMA_ARBITRARY=1
29+
30+
volumes:
31+
db:
32+
33+

env/mysql.env

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
MYSQL_ROOT_PASSWORD=@Qrtyac11
2+
MYSQL_DATABASE=issuetrackdb
3+
MYSQL_USER=fikradev
4+
MYSQL_PASSWORD=qrtyac11

frontend/Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM php:8.0-apache
2+
3+
RUN docker-php-ext-install mysqli && docker-php-ext-enable mysqli
4+
5+
COPY . /var/www/html/
6+
7+
USER 1000
8+
9+
EXPOSE 80
10+
11+
CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]

frontend/dbconnect.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
$conn = mysqli_connect('webappdb', '${MYSQL_USER}', '${MYSQL_PASSWORD}', '${MYSQL_DATABASE}');
3+
4+
if($conn == false){
5+
die("ERROR - Could not connect: " . mysqli_connect_error());
6+
}
7+
?>

frontend/footer.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!-- <?php ?> -->
2+
<div class="text-center text-dark">
3+
Copyright &copy; 2022 - fikradev Kingston | Jamaica
4+
</div>
5+
6+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
7+
8+
</body>
9+
10+
</html>

frontend/header.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
ob_start();
3+
?>
4+
<!DOCTYPE html>
5+
<html lang="en">
6+
7+
<head>
8+
<meta charset="UTF-8">
9+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
10+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
11+
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
12+
<link rel="stylesheet" href="./style.css" type="text/css">
13+
14+
15+
<title>Issue Tracker | Login</title>
16+
</head>
17+
18+
<body>

frontend/index.php

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
<?php include('./header.php') ?>
2+
<?php
3+
$errors = array('client_email' => '', 'pwd1' => '', 'pwd2' => '', 'pwd22' => '');
4+
5+
if (isset($_POST['submit'])) {
6+
$valid = true;
7+
8+
if (empty($_POST['client_email'])) {
9+
$valid = false;
10+
$errors['client_email'] = 'Required Field!';
11+
} else {
12+
$client_email = htmlspecialchars($_POST['client_email']);
13+
14+
if (!filter_var($client_email, FILTER_VALIDATE_EMAIL)) {
15+
$valid = false;
16+
$errors['client_email'] = 'Email format is not valid!';
17+
}
18+
}
19+
20+
if (empty($_POST['pwd1'])) {
21+
$valid = false;
22+
$errors['pwd1'] = 'Required Field!';
23+
} else {
24+
$pwd1 = hash('sha512', htmlspecialchars($_POST['pwd1']));
25+
}
26+
27+
if (empty($_POST['pwd2'])) {
28+
$valid = false;
29+
$errors['pwd2'] = 'Required Field!';
30+
} else {
31+
$pwd2 = hash('sha512', htmlspecialchars($_POST['pwd2']));
32+
}
33+
34+
//Database Connection
35+
36+
include('./dbconnect.php');
37+
38+
//Create Sql
39+
if ($valid) {
40+
41+
if ($pwd1 != $pwd2) {
42+
$errors['pwd22'] = 'Passwords Do Not Match!!';
43+
} else {
44+
45+
$sql = "INSERT INTO tbl_registration(db_email,db_password, db_passwordconf) VALUES (?,?,?)";
46+
47+
if ($stmt = mysqli_prepare($conn, $sql)) {
48+
49+
mysqli_stmt_bind_param($stmt, "sss", $client_email, $pwd1, $pwd2);
50+
51+
$client_email = $_REQUEST['client_email'];
52+
$pwd1 = $_REQUEST['pwd1'];
53+
$pwd2 = $_REQUEST['pwd2'];
54+
55+
if (mysqli_stmt_execute($stmt)) {
56+
header('Location: success.php');
57+
exit();
58+
} else {
59+
echo "ERROR - Query Error: $sql. " . mysqli_error($conn);
60+
}
61+
} else {
62+
echo "ERROR: Could not prepare query: $sql. " . mysqli_error($conn);
63+
}
64+
65+
mysqli_stmt_close($stmt);
66+
67+
mysqli_close($conn);
68+
}
69+
}
70+
}
71+
?>
72+
<!DOCTYPE html>
73+
<html lang="en">
74+
75+
76+
77+
<div class="container d-flex justify-content-center align-items-center" style="min-height:85vh">
78+
79+
<form method="POST" action="index.php" class="w-75">
80+
81+
<div class="align-items-center flex-column row">
82+
83+
<div class="col-6 mb-4 text-center">
84+
<h3 class="text-dark fw-bold">I2T Registration Form</h3>
85+
</div>
86+
<div class="col-md-6 col-sm-8 mb-3">
87+
<label class="form-label text-dark fw-bold" for="name">Email Address</label>
88+
89+
<input class="form-control border-secondary" name="client_email" type="text">
90+
<p class="fw-bold text-danger"><?php echo $errors['client_email']; ?></p>
91+
92+
</div>
93+
94+
<div class="col-md-6 col-sm-8 mb-3">
95+
<label class="form-label text-dark fw-bold" for="password1">Password</label>
96+
97+
<input class="form-control border-secondary" name="pwd1" required type="password">
98+
<p class="fw-bold text-danger"><?php echo $errors['pwd1']; ?></p>
99+
</div>
100+
101+
<div class="col-md-6 col-sm-8 mb-3">
102+
<label class="form-label text-dark fw-bold" for="password2">Confirm Password</label>
103+
104+
<input class="form-control border-secondary" name="pwd2" required type="password">
105+
<p class="fw-bold text-danger"><?php echo $errors['pwd2']; ?></p>
106+
<p class="fw-bold text-danger"><?php echo $errors['pwd22']; ?></p>
107+
</div>
108+
109+
110+
<div class="col-md-6 col-sm-8 d-flex justify-content-center mb-3">
111+
<input class="btn btn-success fw-bold" name="submit" type="submit" value="Submit">
112+
</div>
113+
114+
</div>
115+
</form>
116+
</div>
117+
118+
</html>
119+
<?php include('./footer.php') ?>

frontend/php.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
buffer_output = on

frontend/style.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
body{
2+
background: #fff;
3+
4+
}

frontend/success.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php include('./header.php') ?>
2+
<div class="text-center fw-bold">
3+
4+
5+
6+
7+
8+
<div class="alert alert-success" role="alert">
9+
<strong><h2>Record Inserted Successfully!!</h2></strong>
10+
</div>
11+
12+
13+
14+
15+
</div>
16+
<?php include('./footer.php') ?>

0 commit comments

Comments
 (0)