-
Notifications
You must be signed in to change notification settings - Fork 4
/
runs-edit.php
116 lines (75 loc) · 3.09 KB
/
runs-edit.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<?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("Run Type Edit");
navbar('bgimg_index_logged');
HelpButton();
pageFade();
if( isset($_POST['Edit']) ) {
$conn = connect_db();
$sql = "UPDATE runs SET name='". $_POST['name'] ."', note='". htmlspecialchars($_POST['note']) ."' WHERE id_run=". $_POST['id'];
$res = mysqli_query($conn, $sql);
if ($res) {
echo '<script>
swal({
title: "Successfully edited!!",
text: "Run Type 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 runs WHERE id_run=". $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 Run Type No.<?php echo $id; ?></p>
<form method="post" action="">
<input type="hidden" name="id" value="<?php echo $id; ?>" />
<div style="margin-left: 30%; margin-top: -4%;">
<b><label for="name" style="font-size: 1.5vw;">Run Type 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: 30%; max-width: 40%; font-size: 1.25vw;" required />
<div style="margin-top: 5%;">
<b><label for="note" class="w3-text-light-grey" style="font-size: 2vw;">Run Type 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: 40%; resize: none; height: 10rem; 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: 2%; margin-left: -50%; 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>