HUSTLE HARD Posted October 23, 2012 Share Posted October 23, 2012 (edited) Im having a problem with my popup ajax register, on my login.php i have the html code for the captha is implemented in, once submitted my ajax register checks all the information in a sperate file which is ajax_register.php how ever the captcha does not function properly i also tried adding in method post and get did not work it wont pick up what being typed into the input for the captcha. This is the html form in the login.php <form action="ajax_register.php" method="post" id="registerForm"> <br /> <table width="100%" cellspacing="1"> <tr> Username<br /> <input name="username" id="username" onkeyup="CheckUsername(this.value);" type="text"/><br /> Password<br /> <input id="pw1" name="password" onkeyup="CheckPasswords(this.value);PasswordMatch();" type="password" /><br /> Confirm Password<br /> <td><input name="cpassword" id="pw2" onkeyup="PasswordMatch();" type="password" /><br /> Email<br /> <input id="email" name="email" onkeyup="CheckEmail(this.value);" type="email" /><br /> Gender<br /> <select name="gender" id="gender" type="dropdown"> <option value="Male">Male</option> <option value="Female">Female</option> </select><br /><br /> <?php if($set['regcap_on']) { echo "<img src='captcha_verify.php'/><br /> <input name='code' type='text' />"; } ?> </td> </tr> </table><br /> <div align="center"> <input type="submit" name="submit" value="Done" class="regbutton"> </div> <br /> <div id="callback" style="text-align: center;margin: 0 auto;color: black;background: #FFD9C8; border: 1px solid #F0BAA2;padding: 10px;opacity: 0.7;color:##232D30;width:80%;display: none; "> </div> <br /> </form> this is my ajax_register.php <?php include "config.php"; global $_CONFIG; define("MONO_ON", 1); require "class/class_db_{$_CONFIG['driver']}.php"; $db=new database; $db->configure($_CONFIG['hostname'], $_CONFIG['username'], $_CONFIG['password'], $_CONFIG['database'], $_CONFIG['persistent']); $db->connect(); $c=$db->connection_id; require "global_func.php"; $set=array(); $settq=$db->query("SELECT * FROM settings"); while($r=$db->fetch_row($settq)) { $set[$r['conf_name']]=$r['conf_value']; } $extract = explode('&',$_POST['data']); foreach($extract as $e) { $data = explode('=',$e); $form[$data[0]] = urldecode($data[1]); } $username = ( isset($form['username'])&&preg_match("/^[a-z0-9_]+([\\s]{1}[a-z0-9_]|[a-z0-9_])+$/i", $form['username'])&&((strlen($form['username'])<32)&&(strlen($form['username'])>=3)) )?$form['username']:''; if($username && $form['password'] && $form['cpassword'] && $form['email'] && $form['gender']) { if($set['regcap_on']) { if(md5($_POST['code']) != $_SESSION['key']) die("You've failed the captcha test, please try again!"); } if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $form['email'])) { die("Sorry, this email is invalid <br />".$form['email']); } $sm=100; if($form['promo'] == "Your Promo Code Here") { $sm+=100; } $q=$db->query("SELECT * FROM users WHERE username='{$username}' OR login_name='{$username}'"); $q2=$db->query("SELECT * FROM users WHERE email='{$form['email']}'"); if($db->num_rows($q)) { echo "Username already in use. Choose another."; } else if($db->num_rows($q2)) { echo "E-Mail already in use. Choose another."; } else if($form['password'] != $form['cpassword']) { echo "The passwords did not match, please try again!"; } else { $form['ref'] = abs((int) $form['ref']); $IP = $db->escape($_SERVER['REMOTE_ADDR']); $q=$db->query("SELECT * FROM users WHERE lastip='$IP' AND userid={$form['ref']}"); if($db->num_rows($q)) { die("No creating referral multies. Bad dog."); } if($form['ref']) { $q=$db->query("SELECT * FROM users WHERE userid={$form['ref']}"); $r=$db->fetch_row($q); } $db->query("INSERT INTO users (username, login_name, userpass, level, money, crystals, donatordays, user_level, energy, maxenergy, will, maxwill, brave, maxbrave, hp, maxhp, location, gender, signedup, email, bankmoney, lastip, lastip_signup) VALUES( '{$username}', '{$username}', md5('{$form['password']}'), 1, $sm, 0, 0, 1, 12, 12, 100, 100, 5, 5, 100, 100, 1, '{$form['gender']}', unix_timestamp(), '{$form['email']}', -1, '$IP', '$IP')"); $i=$db->insert_id(); $db->query("INSERT INTO userstats VALUES($i, 10, 10, 10, 10, 10)"); if($form['ref']) { require "global_func.php"; $db->query("UPDATE users SET crystals=crystals+5 WHERE userid={$form['ref']}"); event_add($form['ref'],"For refering $username to the game, you have earned yourself 5 crystals!",$c); $db->query("INSERT INTO referals VALUES('', {$form['ref']}, $i, unix_timestamp(),'{$r['lastip']}','$IP')"); } echo "Congratulations! You have signed up, enjoy the game."; } } else { echo 'You must fill in all fields'; } ?> Edited October 23, 2012 by HUSTLE HARD Quote Link to comment Share on other sites More sharing options...
KyleMassacre Posted October 24, 2012 Share Posted October 24, 2012 Im going to take a shot in the dark here but are you setting a $session['key'] and linking it up with your captcha some where? Cause normally what i thought is for a captcha its just a random set of chars that you set up and a user just copies whats in the image and types it in the text box. In a side note i would hate to fill in a 32 char captcha. So to make sense of this, if your captcha is less that 32 characters in length something is wrong from what im reading and may be infact wrong Quote Link to comment Share on other sites More sharing options...
HUSTLE HARD Posted October 24, 2012 Author Share Posted October 24, 2012 its nothing to do with session, basically due to my register form being on my login.php and all the php checks and stuff on a separate file it is not picking up what is being typed into the captcha input Quote Link to comment 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.