Registration
'; if(!$email_address){ echo "You need to enter an e-mail address.
"; } if(!$username){ echo "You need to enter an username.
"; } if(!$password){ echo "You need to specify a password.
"; }; require 'join_form.inc'; // Show the form again! $have_errors=true; }; /* Let's do some checking and ensure that the user's email address or username does not exist in the database */ if (!$have_errors) { opendb() or die(mysql_error()); $sql_email_check = mysql_query("SELECT email FROM users WHERE email='$email_address'"); $sql_username_check = mysql_query("SELECT username FROM users WHERE username='$username'"); $email_check = mysql_num_rows($sql_email_check); $username_check = mysql_num_rows($sql_username_check); if(($email_check > 0) || ($username_check > 0)){ echo "Error! :
"; if($email_check > 0){ echo "Someone has already signed up with that e-mail!
"; unset($email_address); } if($username_check > 0){ echo "That username is already taken!
"; unset($username); } require 'join_form.inc'; // Show the form again! $have_errors=true; } }; if (!$have_errors){ /* Everything has passed both error checks that we have done. It's time to create the account! */ $db_password = md5($password); // Enter info into the Database. $sql = mysql_query("INSERT INTO users (email, username, password, ". "signup_time, timezone, max_tickers)". " VALUES('$email_address','$username', '$db_password', now(), $timezone, ". "$max_free_tickers)"); if(!$sql){ echo 'DB error. Mmm. Please notify someone.'; } else { $userid = mysql_insert_id(); //pamēģināsim atslēgu piesaistīt šim lietotājam $key_value=mysql_real_escape_string(substr($regkey, 0, 32)); $expected_id=substr($regkey, 32, 8); if($expected_id!==false){ $expected_id=(int)@hexdec($expected_id); } else { $expected_id=0; }; $q="SELECT id FROM regkeys WHERE (id=$expected_id) AND ". "(key_value='$key_value') AND (user_id=0) LIMIT 1"; $rez=mysql_query($q); if (($rez) && (mysql_num_rows($rez)>0)){ //atrada atslēgu lietotājam vēl nepiešķirto! $q="UPDATE regkeys SET user_id=".$userid." WHERE id=$expected_id"; mysql_query($q); mysql_free_result($rez); $key_msg='Registration key was verified OK.'; } else { $key_msg="Registration key was either blank or incorrect.\n ". 'You can enter it later by logging in and going to the Profile page.'; }; // Let's mail the user! $subject = "Your registration at ".$site_title; $message = "Hey, $username, you have successfully registered at $site_addr ! username: $username password: $password $key_msg If you don't remember registering here, let me know (shadow@w-shadow.com). W-Shadow (this is an automatically generated message, don't reply to it)"; echo '
'; if(@mail($email_address, $subject, $message, "From: Tickeri ")){ echo "Registration successful!
Log in
"; } else { echo 'Oops, an error occured when mailing you your info!
'; echo 'You can log in anyway.'; }; echo '
'.$key_msg; echo ''; } //if (!$have_errors)... } } echo "
"; require "footer.inc.php"; ?>