Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <html>
- <head>
- <title>xxxxx</title>
- <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
- </head>
- <body>
- <?php
- if($_POST) {
- $username = $_POST['username'];
- $password = $_POST['password'];
- $confirm = $_POST['confirm'];
- $email = $_POST['email'];
- $username2 = $_POST['username'];
- $password2 = $_POST['password'];
- $confirm2 = $_POST['confirm'];
- $email2 = $_POST['email'];
- $regdate = date("Y-m-d");
- require_once 'config.php';
- $conn = mysql_connect($dbhost,$dbuser,$dbpass) or die ('Error connecting to mysql');
- mysql_select_db($dbname);
- $query = sprintf("SELECT COUNT(id) FROM users WHERE UPPER(username) = UPPER('%s')", mysql_real_escape_string($username));
- $query2 = sprintf("SELECT COUNT(id) FROM users WHERE email = '%s'", mysql_real_escape_string($email));
- $result = mysql_query($query);
- $result2 = mysql_query($query2);
- list($count) = mysql_fetch_row($result);
- list($count2) = mysql_fetch_row($result2);
- function assign_rand_value($num)
- {
- switch($num)
- {
- case "1": $rand_value = "a"; break; case "2": $rand_value = "b"; break; case "3": $rand_value = "c"; break; case "4": $rand_value = "d"; break; case "5": $rand_value = "e"; break; case "6": $rand_value = "f"; break; case "7": $rand_value = "g"; break; case "8": $rand_value = "h"; break; case "9": $rand_value = "i"; break; case "10": $rand_value = "j"; break; case "11": $rand_value = "k"; break; case "12": $rand_value = "l"; break; case "13": $rand_value = "m"; break; case "14": $rand_value = "n"; break; case "15": $rand_value = "o"; break; case "16": $rand_value = "p"; break; case "17": $rand_value = "q"; break; case "18": $rand_value = "r"; break; case "19": $rand_value = "s"; break; case "20": $rand_value = "t"; break; case "21": $rand_value = "u"; break; case "22": $rand_value = "v"; break; case "23": $rand_value = "w"; break; case "24": $rand_value = "x"; break; case "25": $rand_value = "y"; break; case "26": $rand_value = "z"; break; case "27": $rand_value = "0"; break; case "28": $rand_value = "1"; break; case "29": $rand_value = "2"; break; case "30": $rand_value = "3"; break; case "31": $rand_value = "4"; break; case "32": $rand_value = "5"; break; case "33": $rand_value = "6"; break; case "34": $rand_value = "7"; break; case "35": $rand_value = "8"; break;
- case "36": $rand_value = "9"; break;
- }
- return $rand_value;
- }
- $confcode="";
- for($i=1; $i<=10; $i++)
- {
- mt_srand((double)microtime() * 1000000);
- $num = mt_rand(1,36);
- $confcode .= assign_rand_value($num);
- }
- if($count >= 1) { ?><span style='color:red'>Error: that username is taken.</span><br /><?php }
- if ($username != htmlspecialchars($username)) { ?><span style='color:red'>Error: name contains invalid characters.</span><br /><?php }
- if (strlen($username) < 3) { ?><span style='color:red'>Error: name must conain at least 3 characters.</span><br /><?php }
- if($password != $confirm) { ?><span style='color:red'>Error: Passwords do not match!</span><br /><?php }
- if (strlen($password) < 6) { ?><span style='color:red'>Error: password must contain at least 6 cahracters.</span><br /><?php }
- if($count2 >= 1) { ?><span style='color:red'>Error: that email is taken.</span><br /><?php }
- if ($email != htmlspecialchars($email)) { ?><span style='color:red'>Error: email contains invalid characters.</span><br /><?php }
- if (strlen($email) < 6) { ?><span style='color:red'>Error: invalid email.</span><br /><?php }
- if ($count == 0 && $username = htmlspecialchars($username) && strlen($username) > 2 && $count2 == 0 && $email = htmlspecialchars($email) && strlen($email) > 5 && $password = $confirm && strlen($password) > 5) {
- $query = sprintf("INSERT INTO users(username,password,email,regdate,confcode) VALUES ('%s','%s','%s','%s','%s');", mysql_real_escape_string($username2), mysql_real_escape_string(sha1($password2)), mysql_real_escape_string($email2), mysql_real_escape_string($regdate), mysql_real_escape_string($confcode));
- mysql_query($query);
- $to = $email;
- $subject = 'browsergame e-mail address confirmation';
- $message = "
- <p>Hey! Thanks for signing up for the browsergame. Click below to confirm your e-mail address.</p>
- <p><a href='http://www.xxxxxxx.org/confirm.php?email=$email?confcode=$confcode'>below</a></p>";
- $headers = 'From: xxxx@xxx.xx' . "\r\n" .
- 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
- mail($to,$subject,$message,$headers);
- ?>
- <span style='color:green'>Congratulations, you've registered successfully! A confirmation e-mail has been sent to the address you entered.</span><br />
- <?php
- }
- }
- ?>
- <form method='post' action='register.php'>
- Username: <input type='text' name='username' /><br />
- Password: <input type='password' name='password' /><br />
- Confirm Password: <input type='password' name='confirm' /><br />
- Email: <input type='text' name='email' /><br />
- <input type='submit' value='Register!' />
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement