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
1f8a27f5
authored
May 02, 2023
by
alsunj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
254ca3d7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
0 deletions
scripts/htdocs/register.php
scripts/htdocs/register.php
0 → 100644
View file @
1f8a27f5
<?php
$con
=
mysqli_connect
(
'localhost'
,
'root'
,
'root'
,
'unity'
,
'3306'
);
if
(
mysqli_connect_errno
())
{
echo
"1"
;
exit
();
}
//unityst sisestatud uus kasutajanimi ja parool
$username
=
$_POST
[
'name'
];
$password
=
$_POST
[
'password'
];
//bank by default panime 5000
$bank
=
'5000'
;
//päring kus otsitakse eelnevalt sisestatud kasutajanime andmebaasist
$namecheckquery
=
"SELECT username FROM users WHERE username = '"
.
$username
.
"';"
;
//päringu teostamine
$namecheck
=
mysqli_query
(
$con
,
$namecheckquery
)
or
die
(
"2"
);
//ei lase registreerida, kui nimi on olemas juba
if
(
mysqli_num_rows
(
$namecheck
)
>
0
)
{
echo
"nimi olemas"
;
exit
();
}
// tekitab paroolsit hashi
$hash
=
password_hash
(
$password
,
PASSWORD_BCRYPT
);
//päring, mis sisestab tabelisse users kasutajanime, hashi, default pangaseisu.
$insertuserquery
=
"INSERT INTO users (username, hash, bank) VALUES('
$username
', '
$hash
', '
$bank
');"
;
//teostab päringut
mysqli_query
(
$con
,
$insertuserquery
)
or
die
(
"4: ei saa kasutajat lisada"
);
//päring, mis sisestab player tabelisse kasutajanime ja by default 0 kaotust ja 0 võitu
$insertuserquery1
=
"INSERT INTO player (username, loses, wins) VALUES ('
$username
',0,0);"
;
//teostab päringut
mysqli_query
(
$con
,
$insertuserquery1
)
or
die
(
"5: ei saa kasutajat lisada teise tabelisse"
);
echo
(
"0"
);
?>
\ 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