Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
alsunj
/
blackjack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
254ca3d7
authored
May 02, 2023
by
alsunj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
0baa5e54
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
0 deletions
scripts/htdocs/login.php
scripts/htdocs/login.php
0 → 100644
View file @
254ca3d7
<?php
$con
=
mysqli_connect
(
'localhost'
,
'root'
,
'root'
,
'unity'
,
'3306'
);
if
(
mysqli_connect_errno
())
{
echo
"1"
;
exit
();
}
//unitysse sisestatud kasutajanimi ja parool
$username
=
$_POST
[
'name'
];
$password
=
$_POST
[
'password'
];
//päring, mis võtab andmebaasist hashi ja pangaseisu sisestatud kasutajanimele
$namecheckquery
=
"SELECT username, hash, bank FROM users WHERE username= '"
.
$username
.
"';"
;
//teostab päringut
$namecheck
=
mysqli_query
(
$con
,
$namecheckquery
)
or
die
(
"4"
);
//valesti kirjutatud kasutajanimi, ei eksisteeri
if
(
mysqli_num_rows
(
$namecheck
)
!=
1
)
{
echo
"Nime ei eksisteeri"
;
exit
();
}
//salvestab teostatud päringu tulemused
$existinginfo
=
mysqli_fetch_assoc
(
$namecheck
);
//salvestab 'hashi'
$hash
=
$existinginfo
[
'hash'
];
//kontrollib kas krupteerides parool ja hash on samad.
$pwcheck
=
password_verify
(
$password
,
$hash
);
// kui parool on sama, siis väljastab nulli, pärast mida on suur tühik ja väljastatakse pangaseis
if
(
$pwcheck
==
true
)
{
echo
"0
\t
"
.
$existinginfo
[
"bank"
];
}
else
{
echo
"vale parool"
;
exit
();
}
?>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment