Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // This function tests whether the email address is valid
- function isValidEmail($email)
- {
- $pattern = "^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$";
- if (eregi($pattern, $email)
- return true;
- else
- return false;
- }
- ?>
- <div id="content">
- <div id="container">
- <?php
- if ($_POST[verify] != "true")
- {
- ?>
- <div id="content-top" style="font-size: 20; padding-left: 20px;">Create an Account</div><br />
- <form action="" method="post" style="padding-left: 20px; padding-bottom: 30px;" name="register">
- <input type="text" value="Username.." name="username" onClick="this.value = ''" class="register"><br /><br />
- <input type="text" value="Password.." name="password" onClick="this.type = 'password'; this.value = ''";
- class="register"><br /><br />
- <input type="text" value="Confirm your password.." name="confirm" onClick="this.type = 'password'; this.value = ''";
- class="register"><br /><br />
- <input type="text" value="Email.." name="email" onClick="this.value = ''" class="register"><br /><br />
- <select name="flags" class="register">
- <option value="24">Wrath of the Lich King</option>
- <option value="12">Burning Crusade</option>
- <option value="0">Classic</option>
- </select><br /><br />
- <select name="forceLanguage" class="register">
- <option value="enGB">English (UK)</option>
- <option value="enUS">English (US)</option>
- </select><br /><br />
- <input type="hidden" name="verify" value="true">
- <input type="submit" value="Create Account" class="submit-register">
- </form>
- <?php
- } else {
- $username = $_POST[username];
- $password = $_POST[password];
- $confirm = $_POST[confirm];
- $email = $_POST[email];
- $flags = $_POST[flags];
- $forceLanguage = $_POST[forceLanguage];
- $banned = 0;
- $muted = 0;
- mysql_select_db("character", $con);
- if ($username == null) // check if nothing was put into the username field
- echo "<div id='content-top' style='font-size: 20; padding-left: 20px;'>Username field was empty!</div><br />";
- elseif ($password == null) // check if nothing was put into the password field
- echo "<div id='content-top' style='font-size: 20; padding-left: 20px;'>Password field was empty!</div><br />";
- elseif ($confirm == null) // check if nothing was put into the confirm password field
- echo "<div id='content-top' style='font-size: 20; padding-left: 20px;'>Confirm your password field was empty!</div><br />";
- elseif ($email == null) // check if nothing was put into the email field
- echo "<div id='content-top' style='font-size: 20; padding-left: 20px;'>Email field was empty!</div><br />";
- // None of the inputs are blank, so we can now continue validating it
- $UsernameCheck = mysql_query("SELECT login FROM accounts WHERE login = '$username'");
- $EmailCheck = mysql_query("SELECT email FROM accounts WHERE email = '$email'");
- elseif (mysql_num_rows($UsernameCheck) == 1) // check if username is already taken
- echo "<div id='content-top' style='font-size: 20; padding-left: 20px;'>That username is taken!</div><br />";
- elseif (!IsValidEmail($email)) // check if the email is a valid email
- echo "<div id='content-top' style='font-size: 20; padding-left: 20px;'>The email you entered was invalid!</div><br />";
- elseif (mysql_num_rows($EmailCheck) == 1) // check if the email is already taken
- echo "<div id='content-top' style='font-size: 20; padding-left: 20px;'>That email has already been used!</div><br />";
- else
- {
- // the form is valid, and we can now create the account
- mysql_query("INSERT INTO accounts ('login', 'password', 'banned', 'email', 'flags', 'forceLanguage', 'muted')
- VALUES ('$username', '$password', '$banned', '$email', '$flags', '$forceLanguage', 'muted')");
- echo "<div id='content-top' style='font-size: 20; padding-left: 20px;'>Your account has been created<br />You may
- now log in</div><br />";
- }
- }
- ?>
- </div>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement