Dodaj 'nowe_konto.php'

This commit is contained in:
Krystian Rzepa 2018-12-30 15:27:53 +00:00
parent 5a65c1abc3
commit 62e94b8ac7

56
nowe_konto.php Normal file
View File

@ -0,0 +1,56 @@
<title>Rejestracja konta</title>
<form method="POST" action="nowe_konto.php">
<b>Login:</b> <input type="text" name="login"><br>
<b>Hasło:</b> <input type="password" name="haslo1"><br>
<b>Powtórz hasło:</b> <input type="password" name="haslo2"><br>
<input type="submit" value="Zarejestruj" name="register">
</form>
<?php
include 'sql/db_login.php';
mysql_connect("$db_servername", "$db_login", "$db_password");
mysql_select_db("$db_name");
$db = mysqli_connect("$db_servername", "$db_login_tasks", "$db_password_tasks", "$db_name_tasks");
function filter($variable)
{
if(get_magic_quotes_gpc())
$variable = stripslashes($variable);
return mysql_real_escape_string(htmlspecialchars(trim($variable)));
}
if (isset($_POST['register']))
{
$login = filter($_POST['login']);
$haslo1 = filter($_POST['haslo1']);
$haslo2 = filter($_POST['haslo2']);
if (mysql_num_rows(mysql_query("SELECT user_login FROM users WHERE user_login = '".$login."';")) == 0)
{
if ($haslo1 == $haslo2)
{
mysql_query("INSERT INTO `users` (`user_login`, `user_pass`)
VALUES ('".$login."', '".$haslo1."');");
$login = strtolower($login);
mysqli_query($db, "CREATE TABLE IF NOT EXISTS `tasks_$login` (
`ID` int(10) NOT NULL AUTO_INCREMENT,
`task` varchar(180) NOT NULL,
`done` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin2 AUTO_INCREMENT=0");
echo "Konto zostało utworzone! Czekaj na akceptację.";
}
else echo "Hasła nie są takie same!";
}
else echo "Podany login jest już zajęty.";
}
mysql_close();
?>