jack bro Posted April 26, 2009 Share Posted April 26, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/155665-solved-error-with-captcha/ Share on other sites More sharing options...
jack bro Posted April 26, 2009 Author Share Posted April 26, 2009 Solved, has to re arrange code. Jack. Quote Link to comment https://forums.phpfreaks.com/topic/155665-solved-error-with-captcha/#findComment-819569 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.