Jump to content

Recommended Posts

I'm trying to insert captcha into my register page and need to know why this is working, link to register page is http://www.midcity-mafia.com/register/

 

Nothing happens when register form is submitted, here is relevant code:

 

if ($_POST['Submit']){
	// Define post fields into simple variables
	$reg_username = $_POST['reg_username'];
	$pwd2 = $_POST['pwd2'];
	$email = $_POST['email'];
	$email1 = $_POST['email1'];
	$location=strip_tags($_POST['location']);
	$ref = $_POST['ref'];
	$reg_username=trim($reg_username);
	$pwd2=trim($pwd2);
	$today = gmdate('Y-m-d h:i:s');
	$reg_username = stripslashes($reg_username);
	$email = stripslashes($email);
	$quote = stripslashes($quote);
	$reg_username = strip_tags($reg_username);
	$email = strip_tags($email);
	$resp = recaptcha_check_answer ($privatekey,
                                  $_SERVER["REMOTE_ADDR"],
                                  $_POST["recaptcha_challenge_field"],
                                  $_POST["recaptcha_response_field"]);

if (strlen($reg_username) > 3 || strlen($reg_username) < 40){
					$sql_email_check = mysql_query("SELECT email FROM users
            WHERE email='$email' AND status='Alive'");
					$sql_username_check = mysql_query("SELECT username FROM users
            WHERE username='$reg_username'");
					$email_check = mysql_num_rows($sql_email_check);
					$username_check = mysql_num_rows($sql_username_check);

						if($email_check > 0){
							$message= "Your email address has already been used by another player!";
							unset($email);
						}


						if($username_check > 0){
							$message="Your desired username is already in use, please choose another one.";
							unset($reg_username);
						}
					} elseif ($resp->is_valid) { //if captcha is vaild
						$userid = mysql_insert_id();
						$ip = $_SERVER['REMOTE_ADDR'];
						$random_password22=rand(11111,99999999);
						mysql_query("INSERT INTO `user_info` ( `id` , `username`)
VALUES ('', '$reg_username')") or die (mysql_error());
						mysql_query("INSERT INTO users (`id` , `username` , `password` , `regged`, `email`, `location`, `r_ip`)
VALUES ('', '$reg_username', '$pwd2', '$today', '$email', '$location', '$ip')") or die (mysql_error());
						$sql = "UPDATE users SET totalref=totalref+1 WHERE username='$ref'";
						mysql_query($sql) or die("Error executing: $sql" . mysql_error());
						$message= '<font color="#000000"> <br />Account created, </font> <a href="index.php"> 
<font color="#FFFF00">You may now log in.</font></a> ';
} else {
    $message = '$resp->error'; // Captcha error
  }
}

?>

 

Any help is apprechiated thanks.

 

Jack.

Link to comment
https://forums.phpfreaks.com/topic/155665-solved-error-with-captcha/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.