Commit 0baa5e54 by alsunj

Delete register.php

parent 66975d89
Showing with 0 additions and 41 deletions
<?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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment