-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathadmin_add_facebolt.php
67 lines (53 loc) · 1.63 KB
/
admin_add_facebolt.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
<?php
session_start();
$name = $_POST['name'];
$weight = $_POST['weight'];
$attack = $_POST['attack'];
$defense = $_POST['defense'];
$stamina = $_POST['stamina'];
$generation = $_POST['generation'];
$price = $_POST['price'];
$quantity = $_POST['quantity'];
$clone = $_POST['yesNo'];
$image = $_FILES["itemPicture"]["name"];
$image_location = 'upload/'.$image;
include 'secrets.php';
$connection = mysqli_connect(Mydbserver, Mydbid, Mydbpassword, Mydatabase);
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
exit();
}
$sql = "INSERT INTO FaceBolt (name, weight, attack, defense, stamina, quantity, generation, clone, price, picture) VALUES ('{$name}', '{$weight}', '{$attack}', '{$defense}', '{$stamina}', '{$quantity}', '{$generation}', '{$clone}', '{$price}', '{$image_location}')";
// Perform a query, check for error
if (!mysqli_query($connection,$sql)) {
echo("Error description: " . mysqli_error($connection));
}
mysqli_close($connection);
?>
<?php
if ($_FILES["itemPicture"]["type"] == "image/png" || $_FILES["itemPicture"]["type"] == "image/jpg" || $_FILES["itemPicture"]["type"] == "image/jpeg")
{
if ($_FILES["itemPicture"]["error"] > 0)
{
}
else
{
if (file_exists("upload/" . $_FILES["itemPicture"]["name"]))
{
echo $_FILES["itemPicture"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["itemPicture"]["tmp_name"],
"upload/" . $_FILES["itemPicture"]["name"]);
echo "Stored in: " . "upload/" . $_FILES["itemPicture"]["name"];
}
}
}
else
{
}
?>
<?php
header("Location:admin_homepage.html");
?>