<html> <head> <title>Rejestracja konta</title> <link rel="stylesheet" type="text/css" href="style.css"> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <?php $eerror = ""; 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"); $error = "Konto zostało utworzone! Czekaj na akceptację."; } else { $error = "Hasła nie są takie same!"; } } else { $error = "Podany login jest już zajęty."; } } mysql_close(); ?> <div class="registerbox"> <img src="img/avatar.png" class="avatar"> <h1>Rejestracja</h1> <form method="POST" action="nowe_konto.php"> <p>Login</p> <input type="text" name="login" placeholder="Wpisz swój login" required> <p>Hasło</p> <input type="password" name="haslo1" placeholder="Wpisz swoje hasło" required> <p>Powtórz hasło</p> <input type="password" name="haslo2" placeholder="Powtórz hasło" required> <input type="submit" name="register" value="Rejestruj się"> </form> <h2><?php echo $error; ?></h2> </div> </html>