Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- function check_email_address($email) {
- // First, we check that there's one @ symbol,
- // and that the lengths are right.
- if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) {
- // Email invalid because wrong number of characters
- // in one section or wrong number of @ symbols.
- return false;
- }
- // Split it into sections to make life easier
- $email_array = explode("@", $email);
- $local_array = explode(".", $email_array[0]);
- for ($i = 0; $i < sizeof($local_array); $i++) {
- if
- (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&
- ?'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$",
- $local_array[$i])) {
- return false;
- }
- }
- // Check if domain is IP. If not,
- // it should be valid domain name
- if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) {
- $domain_array = explode(".", $email_array[1]);
- if (sizeof($domain_array) < 2) {
- return false; // Not enough parts to domain
- }
- for ($i = 0; $i < sizeof($domain_array); $i++) {
- if
- (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|
- ?([A-Za-z0-9]+))$",
- $domain_array[$i])) {
- return false;
- }
- }
- }
- return true;
- }
- require_once('config.php');
- $username = trim(strtolower($_POST['name']));
- $username = mysql_escape_string($username);
- $email = trim(strtolower($_POST['email']));
- $email = mysql_escape_string($email);
- $pass = trim(strtolower($_POST['pass']));
- $pass = mysql_escape_string($pass);
- $question = trim(strtolower($_POST['question']));
- $question = mysql_escape_string($question);
- $pass2 = trim(strtolower($_POST['pass2']));
- $pass2 = mysql_escape_string($pass2);
- $answer = trim(strtolower($_POST['answer']));
- $answer = mysql_escape_string($answer);
- $noerrors = true;
- if($username)
- {
- $query = "SELECT Username FROM accounts WHERE Username = '$username'";
- $result = mysql_query($query) or die(mysql_error());
- if(strlen($username) > 0 && mysql_num_rows($result) > 0)
- {
- ?>
- <script>
- $.jGrowl("<b><u>Failed</u></b><br>Your Username is already taken.", {
- theme: "error",
- speed: "fast",
- });</script>
- <?php
- $noerrors = false;
- }
- } else {
- ?>
- <script>
- $.jGrowl("<b><u>Failed</u></b><br>Your Username is already taken.", {
- theme: "error",
- speed: "fast",
- });</script>
- <?php
- $noerrors = false;
- }
- if($email)
- {
- if(!check_email_address($email))
- {
- ?>
- <script>
- $.jGrowl("<b><u>Failed</u></b><br>Invaild Email Address Format.", {
- theme: "error",
- speed: "fast",
- });</script>
- <?php
- $noerrors = false;
- }
- } else {
- ?>
- <script>
- $.jGrowl("<b><u>Failed</u></b><br>Invaild Email Address Format.", {
- theme: "error",
- speed: "fast",
- });</script>
- <?php
- $noerrors = false;
- }
- if($pass)
- {
- if(strlen($pass) < 4)
- {
- ?>
- <script>
- $.jGrowl("<b><u>Failed</u></b><br>Password only english letters and numbers,lenght of 4 to 12.", {
- theme: "error",
- speed: "fast",
- });</script>
- <?php
- $noerrors = false;
- }
- } else {
- ?>
- <script>
- $.jGrowl("<b><u>Failed</u></b><br>Password only english letters and numbers,lenght of 4 to 12.", {
- theme: "error",
- speed: "fast",
- });</script>
- <?php
- $noerrors = false;
- }
- if($pass != $pass)
- {
- ?>
- <script>
- $.jGrowl("<b><u>Failed</u></b><br>Confirm Password don't match.", {
- theme: "error",
- speed: "fast",
- });</script>
- <?php
- $noerrors = false;
- }
- if($answer)
- {
- if (preg_match('/[^A-Za-z0-9]/', $answer) && !strlen($answer) > 3 && !strlen($answer) < 32)
- {
- ?>
- <script>
- $.jGrowl("<b><u>Failed</u></b><br>Answer only english letters and numbers,lenght of 4 to 32.", {
- theme: "error",
- speed: "fast",
- });</script>
- <?php
- $noerrors = false;
- }
- } else {
- ?>
- <script>
- $.jGrowl("<b><u>Failed</u></b><br>Answer only english letters and numbers,lenght of 4 to 32.", {
- theme: "error",
- speed: "fast",
- });</script>
- <?php
- $noerrors = false;
- }
- if($noerrors)
- {
- $ins=mysql_query('INSERT INTO accounts(Username,Password,IP,Email,Question,answer) VALUES ("'.$username.'","'.$pass.'","'.$_SERVER['REMOTE_ADDR'].'", "'.$email.'", "'.$question.'", "'.$answer.'")') or die(mysql_error());
- if($ins)
- {
- $result1 = "SELECT * FROM `accounts` WHERE username='$username' and password='$pass'";
- $query = mysql_query($result1);
- $sql2 = mysql_fetch_assoc($query);
- if ($count==1){
- $logued=1;
- $_SESSION["acc"]=$sql2['Username'];
- $_SESSION["uid"]=$sql2['EntityID'];
- echo 'all_ok';
- }
- echo "all_ok";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement