Skip to content

Commit ee0f26c

Browse files
author
Olivier_Luethy
committed
Small refactoring and styling changes
1 parent d96ef87 commit ee0f26c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1127
-792
lines changed

README.md

+9-16
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
<!-- PROJECT LOGO -->
22
<br />
33
<p align="center">
4-
<a href="http://192.168.100.57:3000/Olivier_Luethy/GGames.git">
5-
<img src="images/favicon.ico" alt="Logo" width="80" height="80">
4+
<a href="https://github.com/Oli7000/GGames.git">
5+
<img src="images/shortcut2.jpg" alt="Logo" width="80" height="80">
66
</a>
77

88
<h3 align="center">GGames</h3>
99

1010
<p align="center">
1111
Here I'll explain about what this project is and how you set it up!
1212
<br />
13-
<a href="http://192.168.100.57:3000/Olivier_Luethy/GGames.git/README.md"><strong>Explore the docs »</strong></a>
13+
<a href="https://github.com/Oli7000/GGames/blob/main/README.md"><strong>Explore the docs »</strong></a>
1414
<br />
1515
<br />
16-
<a href="http://192.168.100.57:3000/Olivier_Luethy/GGames.git">View Demo</a>
16+
<a href="https://github.com/Oli7000/GGames.git">View Demo</a>
1717
·
18-
<a href="http://192.168.100.57:3000/Olivier_Luethy/GGames.git/issues">Report Bug</a>
18+
<a href="https://github.com/Oli7000/GGames.git/issues">Report Bug</a>
1919
·
20-
<a href="http://192.168.100.57:3000/Olivier_Luethy/GGames.git/request">Request Feature</a>
20+
<a href="https://github.com/Oli7000/GGames.git/issues">Request Feature</a>
2121
</p>
2222
</p>
2323

@@ -36,6 +36,7 @@
3636

3737
<!-- ABOUT THE PROJECT -->
3838
## About The Project
39+
3940
In the company I worked together with another colleague on a large project. It was a web based software. To realize this project we used the languages PHP and JavaScript. For the database we used MySQL.
4041
During the development of the software I was fascinated by what you can develop with PHP and MySQL.
4142

@@ -52,21 +53,13 @@ After that I decided to continue working on my game store, which was a dream for
5253

5354
It took me quite a long time to program everything perfectly. About 1 to 2 weeks. When I finished a big part of the project, I spent hours fixing the bugs, except for buying games. After about 4 hours I was finally able to finish it and I was so extremely happy to finish something I had worked on for so long.
5455

55-
The logo was made by Nicola Rubin
56-
5756
<!-- INSTALLATION -->
5857
## Installation Guide
58+
5959
1. At first you need to install git on your local computer. For that you need to go to this [website](https://git-scm.com/downloads).
6060
2. Go to your windows explorer and search for a good place for storing this project
6161
3. Now right click on your folder or place and then click on "Git Bash Here"
6262
4. Finally you will see a new program. If you do you only have to enter this
6363
```sh
64-
git clone http://192.168.100.57:3000/Olivier_Luethy/GGames.git
64+
git clone https://github.com/Oli7000/GGames.git
6565
```
66-
<!-- Websites that helped me -->
67-
## Websites that helped me
68-
Issue 1: How to create a parallax scrolling effect? (Benjamin from the company said that I could try to do and implement that on the home page)<br>
69-
Link: https://www.digitalocean.com/community/tutorials/css-pure-css-parallax-de
70-
71-
Issue 2: How to create a login system?<br>
72-
Link: https://www.tutorialrepublic.com/php-tutorial/php-mysql-login-system.php

app/Controllers/WelcomeController.php app/Controllers/GGamesController.php

+29-65
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
class WelcomeController
3+
class GGamesController
44
{
55
/* Die Welcome Seite oder Startseite */
66
public function index()
@@ -12,36 +12,23 @@ public function index()
1212

1313
/* Der Shop */
1414
public function store(){
15-
session_start();
1615

17-
/* Alle Spiele */
18-
$pdo = connectDatabase();
19-
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
16+
$games = new Games();
2017

21-
$statement = $pdo->prepare("SELECT * FROM video_game");
22-
$statement->execute();
23-
$games = $statement->fetchAll();
18+
// Initialize the session
19+
session_start();
2420

21+
/* Alle Spiele */
22+
$getAllGames = $games -> getAllGames();
23+
$getAllGames = $getAllGames -> fetchAll();
24+
2525
/* Gekaufte Spiele */
26-
$pdo = connectDatabase();
27-
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
28-
29-
$statement = $pdo->prepare("SELECT video_game.name, video_game.id, video_game.entwickler, video_game.img, video_game.price FROM video_game
30-
INNER JOIN kaeufe ON kaeufe.fk_video_gameId = video_game.id
31-
INNER JOIN users ON users.id = kaeufe.fk_usersId WHERE users.id = :id");
32-
$statement->bindParam(':id', $_SESSION['id']);
33-
$statement->execute();
34-
$gamesBought = $statement->fetchAll();
26+
$getAllBoughtGames = $games -> getAllBoughtGames();
27+
$getAllBoughtGames = $getAllBoughtGames -> fetchAll();
3528

3629
/* Nicht Gekaufte Spiele */
37-
$pdo = connectDatabase();
38-
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
39-
40-
$statement = $pdo->prepare("SELECT video_game.id, video_game.name, video_game.entwickler, video_game.img, video_game.price FROM video_game
41-
WHERE video_game.id NOT IN (SELECT kaeufe.fk_video_gameId FROM kaeufe WHERE kaeufe.fk_usersId = :id)");
42-
$statement->bindParam(':id', $_SESSION['id']);
43-
$statement->execute();
44-
$gamesNotBought = $statement->fetchAll();
30+
$getAllNotBoughtGames = $games -> getNotBoughtGames();
31+
$getAllNotBoughtGames = $getAllNotBoughtGames -> fetchAll();
4532

4633
require 'app/Views/store.view.php';
4734
}
@@ -66,7 +53,7 @@ public function addGame(){
6653

6754
$games->createGame($name, $entwickler, $img, $price);
6855

69-
header('Location: http://localhost/GGames/shop/store');
56+
header('Location: http://localhost/GGames/store');
7057
}
7158
}
7259

@@ -85,7 +72,7 @@ public function deleteGame(){
8572

8673
$games->removeGame($id);
8774

88-
header('Location: http://localhost/GGames/shop/store');
75+
header('Location: http://localhost/GGames/store');
8976

9077
require 'app/Views/store.view.php';
9178
}
@@ -99,10 +86,6 @@ public function editGame(){
9986

10087
$id = $_GET['id'];
10188

102-
$title = '';
103-
$pdo = connectDatabase();
104-
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
105-
10689
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
10790
$name = $_POST['name'];
10891
$entwickler = $_POST['entwickler'];
@@ -111,7 +94,7 @@ public function editGame(){
11194

11295
$games->changeGame($name, $entwickler, $img, $price, $id);
11396

114-
header('Location: http://localhost/GGames/shop/store');
97+
header('Location: http://localhost/GGames/store');
11598
}else{
11699
$statement = $pdo->prepare('SELECT * FROM video_game WHERE id = :id');
117100
$statement->bindParam(':id', $id);
@@ -130,39 +113,26 @@ public function buyGame(){
130113

131114
$id = $_GET['id'];
132115

133-
$title = '';
134-
$pdo = connectDatabase();
135-
136116
$games->getGame($_SESSION['id'], $id);
137117

138-
header('Location: http://localhost/GGames/shop/store');
118+
header('Location: http://localhost/GGames/store');
139119

140120
require 'app/Views/store.view.php';
141121
}
142122

143123
public function konto(){
144-
session_start();
124+
$games = new Games();
145125

146-
/* Alle Spiele */
147-
$pdo = connectDatabase();
148-
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
126+
// Initialize the session
127+
session_start();
149128

150-
$statement = $pdo->prepare("SELECT * FROM users WHERE email = :email");
151-
$statement->bindParam(':email', $_SESSION['email']);
152-
$statement->execute();
153-
$konto = $statement->fetchAll();
129+
/* Alle Informationen des Nutzers holen */
130+
$konto = $games -> getAllDataFromUser();
131+
$konto = $konto -> fetchAll();
154132

155133
/* Spiele gekauft */
156-
$pdo = connectDatabase();
157-
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
158-
159-
$statement = $pdo->prepare("SELECT video_game.name, video_game.entwickler, video_game.img, video_game.price FROM video_game
160-
INNER JOIN kaeufe ON kaeufe.fk_video_gameId = video_game.id
161-
INNER JOIN users ON users.id = kaeufe.fk_usersId WHERE users.id = :fk_usersId");
162-
$statement->bindParam(':fk_usersId', $_SESSION['id']);
163-
$statement->execute();
164-
$kaeufe = $statement->fetchAll();
165-
134+
$kaeufe = $games -> getAllBoughtGames();
135+
$kaeufe = $kaeufe -> fetchAll();
166136

167137
require 'app/Views/konto.view.php';
168138
}
@@ -175,22 +145,17 @@ public function editKonto(){
175145

176146
$id = $_GET['id'];
177147

178-
$title = '';
179-
$pdo = connectDatabase();
180-
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
181-
182148
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
183149
$email= $_POST['email'];
184150
$username = $_POST['username'];
185151

186152
$games->changeKonto($email, $username, $id);
187153

188-
header('Location: http://localhost/GGames/shop/logout');
154+
header('Location: http://localhost/GGames/logout');
189155
}else{
190-
$statement = $pdo->prepare('SELECT * FROM users WHERE id = :id');
191-
$statement->bindParam(':id', $id);
192-
$statement->execute();
193-
$konto = $statement->fetchAll();
156+
157+
$konto = $games -> getAllDataFromUser();
158+
$konto = $konto -> fetchAll();
194159
}
195160
require 'app/Views/editKonto.view.php';
196161
}
@@ -210,5 +175,4 @@ public function config(){
210175
public function register(){
211176
require 'app/Views/register.view.php';
212177
}
213-
}
214-
178+
}

app/Models/Games.php

+34
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,40 @@ public function __construct()
88
$this->db = connectDatabase();
99
}
1010

11+
/* Alle Spiele anzeigen */
12+
public function getAllGames(){
13+
$statement = $this->db->prepare("SELECT * FROM video_game");
14+
$statement->execute();
15+
return $statement;
16+
}
17+
18+
/* Alle gekauften Spiele anzeigen */
19+
public function getAllBoughtGames(){
20+
$statement = $this->db->prepare("SELECT video_game.name, video_game.id, video_game.entwickler, video_game.img, video_game.price FROM video_game
21+
INNER JOIN kaeufe ON kaeufe.fk_video_gameId = video_game.id
22+
INNER JOIN users ON users.id = kaeufe.fk_usersId WHERE users.id = :id");
23+
$statement->bindParam(':id', $_SESSION['id']);
24+
$statement->execute();
25+
return $statement;
26+
}
27+
28+
/* Alle nicht gekauften Spiele anzeigen */
29+
public function getNotBoughtGames(){
30+
$statement = $this->db->prepare("SELECT video_game.id, video_game.name, video_game.entwickler, video_game.img, video_game.price FROM video_game
31+
WHERE video_game.id NOT IN (SELECT kaeufe.fk_video_gameId FROM kaeufe WHERE kaeufe.fk_usersId = :id)");
32+
$statement->bindParam(':id', $_SESSION['id']);
33+
$statement->execute();
34+
return $statement;
35+
}
36+
37+
/* Alle Informationen des Nutzers holen */
38+
public function getAllDataFromUser(){
39+
$statement = $this->db->prepare("SELECT * FROM users WHERE email = :email");
40+
$statement->bindParam(':email', $_SESSION['email']);
41+
$statement->execute();
42+
return $statement;
43+
}
44+
1145
/* Spiel hinzufügen */
1246
public function createGame($name, $entwickler, $img, $price){
1347
$statement = $this->db->prepare("INSERT INTO `video_game` (name, entwickler, img, price) VALUES (:name, :entwickler, :img, :price)");

app/Views/addGame.view.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<meta charset="UTF-8">
55
<meta http-equiv="X-UA-Compatible" content="IE=edge">
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7-
<link rel="shortcut icon" href="../images/favicon.ico">
8-
<link rel="stylesheet" href="../public/css/editPage.css">
7+
<link rel="shortcut icon" href="assets/favicon.ico">
8+
<link rel="stylesheet" href="public/style/editPage.css">
99
<meta name="author" content="Olivier Luethy">
1010
<script src="https://kit.fontawesome.com/a076d05399.js" crossorigin="anonymous"></script>
1111
<link rel="preconnect" href="https://fonts.googleapis.com">
@@ -32,6 +32,6 @@
3232
<button class="reset" type="reset"><i class="fas fa-undo"></i> Reset</button>
3333
<button type="submit" name="form-submit"><i class="fas fa-plus"></i> Spiel hinzufügen</button>
3434
</form>
35-
<script src="../public/js/clientSideValidationGame.js"></script>
35+
<script src="public/js/clientSideValidationGame.js"></script>
3636
</body>
3737
</html>

app/Views/editGame.view.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<head>
55
<meta charset="UTF-8">
66
<title>Spiel bearbeiten</title>
7-
<link rel="shortcut icon" href="../images/favicon.ico">
8-
<link rel="stylesheet" href="../public/css/editPage.css">
7+
<link rel="shortcut icon" href="assets/favicon.ico">
8+
<link rel="stylesheet" href="public/style/editPage.css">
99
<meta name="author" content="Olivier Luethy">
1010
<script src="https://kit.fontawesome.com/a076d05399.js" crossorigin="anonymous"></script>
1111
<link rel="preconnect" href="https://fonts.googleapis.com">
@@ -31,7 +31,7 @@
3131

3232
<button type="submit" name="form-submit"><i class='fas fa-edit'></i> Spiel bearbeiten</button>
3333
</form>
34-
<script src="../public/js/clientSideValidationGame.js"></script>
34+
<script src="public/js/clientSideValidationGame.js"></script>
3535
</body>
3636

3737
</html>

app/Views/editKonto.view.php

+10-4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<head>
55
<meta charset="UTF-8">
66
<title>Konto bearbeiten</title>
7-
<link rel="shortcut icon" href="../images/shortcut2.jpg">
8-
<link rel="stylesheet" href="../public/css/editPage.css">
7+
<link rel="shortcut icon" href="assets/favicon.ico">
8+
<link rel="stylesheet" href="public/style/editPage.css">
99
<meta name="author" content="Olivier Luethy">
1010
<script src="https://kit.fontawesome.com/a076d05399.js" crossorigin="anonymous"></script>
1111
<link rel="preconnect" href="https://fonts.googleapis.com">
@@ -23,9 +23,15 @@
2323
<label for="username">Username:</label><br>
2424
<input type="text" name="username" id="username" value="<?= $konto[0][3] ?>"><br><br>
2525

26-
<button type="submit" name="form-submit"><i class='fas fa-edit'></i> Konto bearbeiten</button>
26+
<label for="passwort">Passwort:</label><br>
27+
<input type="password" name="passwort" id="passwort"><br><br>
28+
29+
<label for="passwort_again">Passwort bestätigen:</label><br>
30+
<input type="password" name="passwort_again" id="passwort_again"><br><br>
31+
32+
<button type="submit" name="form-submit"><i class='fas fa-edit'></i> Konto bearbeiten</button>
2733
</form>
28-
<script src="../public/js/clientSideValidationKonto.js"></script>
34+
<script src="public/js/clientSideValidationKonto.js"></script>
2935
</body>
3036

3137
</html>

0 commit comments

Comments
 (0)