Skip to content

spell miss #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added account.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bell.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions defult.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>タイトルタブ</title>
<style>
</style>
</head>
<body>
<div style="margin: 50px 0px 0px 50px;">
<h1>タイトル</h1>
</div>
<br>
<p style="text-align: center; background-color: gray; border-radius: 30px; margin: 0px 600px; padding: 100px 0px;">
概要
</p>
<div style="text-align: center;">
<button onclick="location.href='login.html'" id="Login" style="position: relative; top: 50px; background-color: bisque; border-radius: 10px; font-size: 30px">ログイン</button>
<button onclick="location.href='register.html'" id="Register" style="position: relative; top: 50px; background-color: bisque; border-radius: 10px; font-size: 30px">新規会員登録</button>
</div>
</body>
</html>
248 changes: 248 additions & 0 deletions home.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,248 @@
<?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();
}

//アップロードが成功したかのチェック
if (isset($_GET['s']) && $_GET['s'] == 1) {
echo '<script>alert("アップロードが成功しました");</script>';
// $url = strtok($_SERVER["REQUEST_URI"], '?');
// header("Location: $url");
// exit();

}
?>

<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8">
<title>ホーム画面</title>
<style>
.parent {
display: flex;
}

.child {
color: black;
border: double;
border-radius: 10px;
border-color: gray;
text-align: center;
width: 300px;
height: 200px;
background-color: bisque;
position: relative;
margin: 100px auto;
padding: auto;
font-size: large;
}
</style>
</head>

<body style="background-color: gray;">
<section>
<div id="upper-bar" style="background-color: blanchedalmond; padding: 10px 10px; border-radius: 10px; border-style:solid; border-color: red;">
<button id="button" aria-pressed="false" style="font-size: 20px; border-radius: 5px;">
</button>
<a href="/defult.html">タイトル</a>
<a href="/personal.php">
<img class="account" src="account.png" style="width: 40px; height: 40px; display: block; float:right; position: relative;">
</a>
<a href="/upload.php">
<img class="bell-mark" src="bell.png" style="width: 30px; height: 30px; display: block; float:right; position: relative; margin-right: 5px; margin-top: 5px;">
</a>
</div>
</section>

<section>
<div id="search-bar">
<form action="search.php" method="get" id="searchform" align="center" style="position: relative; top: 50px">
<input type="search" name="search" id="search" placeholder="検索" style="padding: 10px; width: 250px; font-size: 1.1em; height: 10px; border-radius: 5px;">
<button type="submit" id="search-button" style="font-size: 20px; padding: 2px; border-radius: 5px;">
search
</button>
</form>
</div>
</section>

<?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();
}

// クエリを実行して結果を取得
$sql = "SELECT SongName, COUNT(*) as count FROM SongList GROUP BY SongName ORDER BY count DESC LIMIT 10";
$result = $mysqli->query($sql);
$n = 1;
?>


<section>
<div class="parent">
<div class="child">
<p>
<?php
// 結果の1位のレコードを取得
$row = $result->fetch_assoc();
$name = $row['SongName'];
$count = $row['count'];
// 1位を表示
echo "<p>第" . $n . "位" . "<br>" . "<br>" . $name . "<br>" . "<br>" . $count . "件</p>";
$n += 1;
?>
</p>
</div>
<div class="child">
<p>
<?php
// 2位を表示
$row = $result->fetch_assoc();
$name = $row['SongName'];
$count = $row['count'];
echo "<p>第" . $n . "位" . "<br>" . "<br>" . $name . "<br>" . "<br>" . $count . "件</p>";
$n += 1;
?>
</p>
</div>
<div class="child">
<p>
<?php
// 3位を表示
$row = $result->fetch_assoc();
$name = $row['SongName'];
$count = $row['count'];
echo "<p>第" . $n . "位" . "<br>" . "<br>" . $name . "<br>" . "<br>" . $count . "件</p>";
$n += 1;
?>
</p>
</div>
<div class="child">
<p>
<?php
// 4位を表示
$row = $result->fetch_assoc();
$name = $row['SongName'];
$count = $row['count'];
echo "<p>第" . $n . "位" . "<br>" . "<br>" . $name . "<br>" . "<br>" . $count . "件</p>";
$n += 1;
?>
</p>
</p>
</div>
<div class="child">
<p>
<?php
// 5位を表示
$row = $result->fetch_assoc();
$name = $row['SongName'];
$count = $row['count'];
echo "<p>第" . $n . "位" . "<br>" . "<br>" . $name . "<br>" . "<br>" . $count . "件</p>";
$n += 1;
?>
</p>
</p>
</div>
</div>
</section>
<section>
<div class="parent">
<div class="child">
<p>
<?php
// 6位を表示
$row = $result->fetch_assoc();
$name = $row['SongName'];
$count = $row['count'];
echo "<p>第" . $n . "位" . "<br>" . "<br>" . $name . "<br>" . "<br>" . $count . "件</p>";
$n += 1;
?>
</p>
</p>
</div>
<div class="child">
<p>
<?php
// 7位を表示
$row = $result->fetch_assoc();
$name = $row['SongName'];
$count = $row['count'];
echo "<p>第" . $n . "位" . "<br>" . "<br>" . $name . "<br>" . "<br>" . $count . "件</p>";
$n += 1;
?>
</p>
</p>
</div>
<div class="child">
<p>
<?php
// 8位を表示
$row = $result->fetch_assoc();
$name = $row['SongName'];
$count = $row['count'];
echo "<p>第" . $n . "位" . "<br>" . "<br>" . $name . "<br>" . "<br>" . $count . "件</p>";
$n += 1;
?>
</p>
</p>
</div>
<div class="child">
<p>
<?php
// 9位を表示
$row = $result->fetch_assoc();
$name = $row['SongName'];
$count = $row['count'];
echo "<p>第" . $n . "位" . "<br>" . "<br>" . $name . "<br>" . "<br>" . $count . "件</p>";
$n += 1;
?>
</p>
</p>
</div>
<div class="child">
<p>
<?php
// 10位を表示
$row = $result->fetch_assoc();
$name = $row['SongName'];
$count = $row['count'];
echo "<p>第" . $n . "位" . "<br>" . "<br>" . $name . "<br>" . "<br>" . $count . "件</p>";
$n += 1;
?>
</p>
</p>
</div>
</div>
</section>
</body>

</html>

<?php // 切断
$mysqli->close();
?>
25 changes: 23 additions & 2 deletions identify.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

session_start();

// 接続
$mysqli = new mysqli('localhost', 'root', 'root', 'User authentication');
Expand All @@ -19,7 +21,7 @@
$hashedPassword = hash('sha256', $password);

// データを認証する
$sql = "SELECT * FROM `User` WHERE `username` LIKE '" .$hashedUsername. "' AND `passward` LIKE '" .$hashedPassword. "'";//クエリ
$sql = "SELECT * FROM `User` WHERE `username` LIKE '" .$hashedUsername. "' AND `password` LIKE '" .$hashedPassword. "'";//クエリ

$result = $mysqli->query($sql);
//echo $result -> num_rows;
Expand All @@ -28,10 +30,29 @@
echo '認証に失敗しました。'.mysqli_error();
}else{
echo '認証に成功しました';
header("location: index.html");

// パスワードが正しい場合、セッションを開始
$_SESSION['authenticated'] = true;
$_SESSION['username'] = $username;

// 10秒後にセッションを終了するためにタイマーを設定
$_SESSION['expire_time'] = time() + 10;

// index.htmlにリダイレクト
header('Location: index.php');
exit();
}

if(isset($_POST['back'])) {
header("location: login.html");
}

// 切断
$mysqli->close();

?>

<form action="login.php" method="post">
<input type="submit" name="back" value="ログイン画面に戻る" />
</form>

22 changes: 22 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?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: login.html');
exit();
}
} else {
// セッションが開始されていない場合、login.htmlにリダイレクト
header('Location: login.html');
exit();
}
?>


Loading