-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathweapons-edit.php
More file actions
124 lines (80 loc) · 3.51 KB
/
weapons-edit.php
File metadata and controls
124 lines (80 loc) · 3.51 KB
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php
//ob_start();
session_start();
// If User is logged => redirect to tavern.php and announce it
if ( !isset($_SESSION['user']) ) {
$_SESSION['logged'] = 1;
header("Location: tavern.php");
echo "<meta http-equiv='refresh' content='0; url=tavern.php'>";
exit;
}
require_once 'inc.php';
html_head("Weapon Edit");
navbar('bgimg_index_logged');
HelpButton();
pageFade();
if( isset($_POST['Edit']) ) {
$conn = connect_db();
$sql = "UPDATE weapons SET name='". $_POST['name'] ."', img='". $_POST['image'] ."', note='". htmlspecialchars($_POST['note']) ."' WHERE id_weapon=". $_POST['id'];
$res = mysqli_query($conn, $sql);
if ($res) {
echo '<script>
swal({
title: "Successfully edited!!",
text: "Weapon has been edited without any problem!",
type: "success",
showConfirmButton: false,
timer: 1990
});
</script>';
echo "<meta http-equiv='refresh' content='2; url=tavern.php'>";
} else {
mysqli_error($conn);
}
mysqli_close($conn);
}
if( isset($_POST['value']) ) $id = $_POST['value'];
else $id = $_POST['id'];
$conn = connect_db();
$sql = "SELECT * FROM weapons WHERE id_weapon=". $id;
$res = mysqli_query($conn, $sql);
$set = mysqli_fetch_array($res, MYSQLI_ASSOC);
mysqli_close($conn);
$noteValue = 255 - strlen($set['note']);
?>
<script>
$(function() {
$source=$("#name");
$output=$("#result");
$source.keyup(function() {
$output.text($source.val());
});
});
</script>
<div class="w3-text-light-grey Oswald">
<p class="w3-center" style="margin-top: -2%; font-size: 5vw;">Edit of Difficulty No.<?php echo $id; ?></p>
<form method="post" action="">
<div style="margin-top: -2%;">
<input type="hidden" name="id" value="<?php echo $id; ?>" />
<div class="w3-half" style="padding-left: 25%;">
<b><label for="name" style="font-size: 1.5vw;">Weapon Name: </label></b>
<input type="text" class="w3-input w3-animate-input w3-transparent w3-text-light-grey w3-center w3-margin-top" placeholder="Fill in the Name..." value="<?php echo $set['name']; ?>" name="name" id="name" style="width: 70%; max-width: 90%; font-size: 1.25vw;" required />
<br /><br />
<b><label for="image" style="font-size: 1.5vw;">Image Link: </label></b>
<input type="text" class="w3-input w3-animate-input w3-transparent w3-text-light-grey w3-center w3-margin-top" placeholder="Fill in the Image Link..." value="<?php echo $set['img']; ?>" name="image" id="image" style="width: 70%; max-width: 90%; font-size: 1.25vw;" />
</div>
<div class="w3-half" style="padding-left: 5%;">
<b><label for="note" class="w3-text-light-grey" style="font-size: 2vw;">Weapon Description: </label></b><br />
<textarea class="w3-transparent w3-text-light-grey w3-border-0 w3-leftbar" onKeyDown="limitText(this.form.note,this.form.countdown,255);"
onKeyUp="limitText(this.form.note,this.form.countdown,255);" name="note" id="note" style="width: 50%; resize: none; height: 14rem; padding-left: 2%; font-size: 1vw;"><?php echo htmlspecialchars($set['note']); ?></textarea>
<input class="w3-input w3-transparent w3-text-light-grey w3-center" name="countdown" value="<?php echo $noteValue; ?>" style="width: 10%;" /> characters left
</div>
<div class='w3-center' style='margin-top: 4%; font-size: 1.5vw;'>
<input type='submit' value='Edit' name='Edit' class='w3-btn w3-transparent w3-text-green w3-border w3-border-green w3-padding-large' />
<input type='reset' value='Reset' class='w3-btn w3-transparent w3-text-red w3-border w3-border-red w3-padding-large' style='margin-left: 5%;' />
</div>
</div>
</form>
</div>
</body>
</html>