-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupload(old).php
150 lines (117 loc) · 4.21 KB
/
upload(old).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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<?php
// セッションをチェック
session_start();
if ($_SESSION['authenticated']) {
echo "<p>Welcome, " . $_SESSION['username'] . "!</p>";
// セッションが有効期限切れになったかどうかをチェック
if (time() > $_SESSION['expire_time']) {
// セッションを終了して、login.htmlにリダイレクト
session_unset();
session_destroy();
header('Location: defult.html');
exit();
}
} else {
// セッションが開始されていない場合、login.htmlにリダイレクト
header('Location: defult.html');
exit();
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="upload.css" type="text/css">
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
</head>
<body>
<hgroup>
<h1>楽曲アップロードページ</h1>
<!-- <h3>By Josh Adamous</h3> -->
</hgroup>
<form action="http://localhost/upload.php?" method="get">
<div class="group">
<input name="SongName" value="" /><span class="highlight"></span><span class="bar"></span>
<label>曲名</label>
</div>
<div class="group">
<input name="SongPart" value="" /><span class="highlight"></span><span class="bar"></span>
<label>演奏パート</label>
</div>
<div class="group">
<input name="SongTempo" value="" /><span class="highlight"></span><span class="bar"></span>
<label>設定テンポ</label>
</div>
<div class="group">
<input name="SongUrl" value="" /><span class="highlight"></span><span class="bar"></span>
<label>Url</label>
</div>
<button type="submit" class="button buttonBlue">Upload
<div class="ripples buttonRipples"><span class="ripplesCircle"></span></div>
</button>
</form>
<footer><a href="http://www.polymer-project.org/" target="_blank"><img src="https://www.polymer-project.org/images/logos/p-logo.svg"></a>
<p>You Gotta Love <a href="http://www.polymer-project.org/" target="_blank">Google</a></p>
</footer>
</body>
</html>
<script>
$(window, document, undefined).ready(function() {
$('input').blur(function() {
var $this = $(this);
if ($this.val())
$this.addClass('used');
else
$this.removeClass('used');
});
var $ripples = $('.ripples');
$ripples.on('click.Ripples', function(e) {
var $this = $(this);
var $offset = $this.parent().offset();
var $circle = $this.find('.ripplesCircle');
var x = e.pageX - $offset.left;
var y = e.pageY - $offset.top;
$circle.css({
top: y + 'px',
left: x + 'px'
});
$this.addClass('is-active');
});
$ripples.on('animationend webkitAnimationEnd mozAnimationEnd oanimationend MSAnimationEnd', function(e) {
$(this).removeClass('is-active');
});
});
</script>
<?php
// 接続
$mysqli = new mysqli('localhost', 'root', 'root', 'music_data');
//接続状況の確認
if (mysqli_connect_errno()) {
echo "データベース接続失敗" . PHP_EOL;
echo "errno: " . mysqli_connect_errno() . PHP_EOL;
echo "error: " . mysqli_connect_error() . PHP_EOL;
exit();
}
$SongName = $_GET['SongName'];
$SongPart = $_GET['SongPart'];
$SongTempo = $_GET['SongTempo'];
$SongUrl = $_GET['SongUrl'];
$hashedUserName = hash('sha256', $_SESSION['username']);
$UserName = $_SESSION['username'];
// データを挿入する
$sql = "INSERT INTO `SongList` (`SongName`, `SongPart`, `SongTempo`, `SongUrl`, `UserName`) VALUES ('" . $SongName . "', '" . $SongPart . "', '" . $SongTempo . "', '" . $SongUrl . "', '" . $UserName . "');"; //クエリ
$result = $mysqli->query($sql);
if (!$result) {
//echo 'INSERTが失敗しました。' . mysqli_error();
} else {
//echo 'INSERTが成功しました。';
header("Location: home.php?s=1");
}
// 切断
$mysqli->close();
// if (!empty($_SERVER['QUERY_STRING'])) {
// $url = strtok($_SERVER["REQUEST_URI"], '?');
// header("Location: $url");
// exit();
// }
?>