Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if ($_POST['register']) {
- if ($_POST['username'] && $_POST['password'] && $_POST['passwordconfirm'] && $_POST['fullname']) {
- $username = mysql_real_escape_string($_POST['username']);
- $password = mysql_real_escape_string(hash("sha512", $_POST['password']));
- $passwordconfirm = mysql_real_escape_string(hash("sha512", $_POST['password']));
- $fullname = my_real_escape_string($_POST['fullname']);
- if ($_POST['fullname']) {
- $name = mysql_real_escape_string(strip_tags($_POST['name']));
- };
- $check = mysql_fetch_array(mysql_query("SELECT * FROM 'users' WHERE 'Username='$username'"));
- if ($check != '0') {
- die("That username already exists! Click <a href='http://growtapians.com/Login & Register System/register.php'>here</a> and try entering a different one.");
- };
- if(!ctype_alnum($username)) {
- die("Sorry, but only numbers and letters are allowed in the username. Click <a href='http://growtapians.com/Login & Register System/register.php'>here</a> and try removing all special characters!");
- };
- if (strlen($username) > 20) {
- die("The username cannot be more than 20 characters long. Click <a href='http://growtapians.com/Login & Register System/register.php'>here</a> and try shortening your username!");
- };
- if ($password != $passwordconfirm) {
- die("The passwords did not match! Click <a href='http://growtapians.com/Login & Register System/register.php'>here</a> and try again!");
- };
- $salt = hash("sha512", rand() . rand() . rand());
- mysql_query("INSERT INTO 'users' ('Username', 'Password', 'Name', 'Salt') VALUES ('$username', '$password', '$fullname', '$salt')");
- setcookie("c_user", hash("sha412", $username), time() + 24 * 60 * 60, "/");
- setcookie("c_salt", $salt, time() +24 * 60 * 60, "/");
- die("Registration successful!");
- };
- };
- <!DOCTYPE html>
- <html lang='en'>
- <head>
- <meta charset='UTF-8'>
- <meta name='viewport' content='width=device, height=device=height, initial-scale=1'>
- <style media='screen'>
- body {
- font: 1em/1.62em verdana, sans-serif;
- background-color: #249EC7;
- }
- form {
- max-width: 58em;
- padding: .2em;
- margin: auto;
- background-color: #648cd1;
- color: #31d8eb;
- text-align: center;
- }
- form div {
- margin: 0em 1em 1em 1em;
- }
- form b {
- font-size: 1.3em;
- }
- form b,form input{
- display: inline-block;
- width: 12em;
- }
- form input {
- padding: 0.25em;
- }
- h4 a:visited {
- color: #F56433;
- }
- #logindiv {
- height: 18.5em;
- margin-top: -9.25em;
- </style>
- <body>
- <div id='logindiv' style='width: 50%; padding: 10px; border: 5px solid #316ED6; background-color: #648CD1; color: #31D8EB; margin: auto; text-align: center;'>
- <h1>Login</h1>
- <br />
- <form action='' method='post'>
- <div>
- <b>Username:</b>
- <input type='text' name='username' style='padding: 4px;'/>
- </div>
- <div>
- <b>Password:</b>
- <input type='password' name='password' style='padding: 4px; '/>
- </div>
- <div>
- <input type='submit' value='Login' name='login'/>
- </div>
- </form>
- <div>
- <h4>No Account? Register <a href='register.php'>Here!</a></h4>
- </div>
- </div>
- </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement