Skip to content
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
2 changes: 1 addition & 1 deletion identify.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,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 Down
1 change: 1 addition & 0 deletions index2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
aaa
5 changes: 3 additions & 2 deletions login.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

<body>

<!-- 新規登録 -->
<form action="http://localhost/login.php" method="POST" onsubmit="hashCredentials()">
<p>新規登録</p>
<label for="username">Username:</label>
Expand Down Expand Up @@ -36,9 +37,9 @@

<script>
function hashCredentials() { //ハッシュ化
var usernameInput = document.getElementById('username');
var usernameInput = document.getElementById('username');
var passwordInput = document.getElementById('password');
var hashedUsername = sha256(usernameInput.value);
var hashedUsername = sha256(usernameInput.value);
var hashedPassword = sha256(passwordInput.value);
usernameInput.value = hashedUsername;
passwordInput.value = hashedPassword;
Expand Down
6 changes: 4 additions & 2 deletions login.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,19 @@
exit();
}

// $username = hash_hmac('sha512', $_POST['username'] , 'secret', false);
// $passward = hash_hmac('sha512', $_POST['passward'] , 'secret', false);
$username = $_POST['username'];
$password = $_POST['password'];
$hashedUsername = hash('sha256', $username);
$hashedPassword = hash('sha256', $password);


// データを挿入する
$sql = "INSERT INTO `User` (`username`, `passward`) VALUES ('" .$hashedUsername. "', '" .$hashedPassword. "');";//クエリ
$sql = "INSERT INTO User (`username`, `password`) VALUES ('" .$hashedUsername. "', '" .$hashedPassword. "');";//クエリ

$result = $mysqli->query($sql);

if (!$result) {
echo 'INSERTが失敗しました。'.mysqli_error();
}else{
Expand Down
1 change: 1 addition & 0 deletions test.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
aaa