This repository has been archived by the owner on Mar 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
add.php
99 lines (91 loc) · 3.73 KB
/
add.php
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
session_start();
$servername = "localhost";
$username = "root";
$dbPassword = "";
$dbname = "bayconegg";
// Create connection
$conn = new mysqli($servername, $username, $dbPassword, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if ($_SESSION["email"] != "admin@bayconeggs.com" ) {
echo '
<script>
alert("You do not have access to this page! ⊂(⊙д⊙)つ");
window.location = "index.php";
</script>';
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Baycon & E.GG</title>
<link rel="stylesheet" type="text/css" href="css/add.css">
<link rel="stylesheet" type="text/css" href="css/navbar.css">
<link rel="stylesheet" type="text/css" href="css/footer.css">
</head>
<body>
<?php include "navbar.php"; ?>
<?php
if(isset($_POST['add']) && $_POST['add']==1) {
$gameNameUpdate = $_POST['game-name'];
$gameDescUpdate = $_POST['game-desc'];
$gamePicUpdate = $_POST['game-pic'];
$gamePrice_RMUpdate = $_POST['game-price'];
echo "Name: " . $gameNameUpdate . "<br>";
echo "Description: " . $gameDescUpdate . "<br>";
echo "Picture: " . $gamePicUpdate . "<br>";
echo "Price : " . $gamePrice_RMUpdate . "<br>";
$sql="INSERT INTO games (gameName, gameDesc, gamePic, gamePrice_RM)
VALUES ('$gameNameUpdate','$gameDescUpdate','$gamePicUpdate','$gamePrice_RMUpdate');";
if (mysqli_query($conn, $sql)) {
echo '
<script>
alert("You have added the data successfully. \( ゚ヮ゚)/");
window.location = "admin.php";
</script>
';
} else {
echo '
<script>
alert("Error when adding data. ┏༼ ◉ ╭╮ ◉༽┓ \n The error was: "'. $conn->error . '");
window.location = "admin.php";
</script>
';
}
}
else { ?>
<table id="add-game-table">
<caption>Add Game</caption>
<form method="POST" action="">
<tr>
<td id="table-column-label"><label for="game-name">Game Name</label></td>
<td id="table-column-input"><input id="game-name" type="text" name="game-name" required placeholder="Insert Game Name"></td>
</tr>
<tr>
<td><label for="game-desc">Game Description</label></td>
<td><textarea id="game-desc" name="game-desc" required cols="50" rows="10" placeholder="Insert Description Here"></textarea></td>
</tr>
<tr>
<td><label for="game-pic">Game Picture</label></td>
<td><input id="game-pic" type="text" name="game-pic" required placeholder="Remember to upload pictures to images/products"></td>
</tr>
<tr>
<td><label for="game-price">Game Price</label></td>
<td><input id="game-price" type="text" name="game-price" required placeholder="Insert Game Price"></td>
</tr>
<tr>
<td id="table-row-add" colspan="2"><input type="submit" value="Add"></td>
</tr>
<input type="hidden" name="add" value="1" />
</form>
</table>
<?php };?>
<?php include "footer.php"; ?>
<script src="js/add.js"></script>
</body>
</html>