monkeytooth Posted November 12, 2009 Share Posted November 12, 2009 Now the thing I am having an issue with is, I did have this working a little while ago, then I decided to rearange my layout a bit, but other then the layout itself none of the coding was altered that i recall for this particular part, however it stopped working. And I cant figure it out, im 2 steps shy of throwing my keyboard against the all, so I think i need to stop for a minute and gather some 3rd party perspectives on this, cause I dunno what i did to make it stop. Would any of you mind sniffing through and see if you see something a miss that I'm not seeing JQuery <script type='text/javascript'> $(document).ready(function(){ $('#regiForm').submit(function(e) { register(); e.preventDefault(); }); }); function register(){ hideshow('loading',1); error(0); $.ajax({ type: "POST", url: "subreg.php", data: $('#regiForm').serialize(), dataType: "json", success: function(msg){ if(parseInt(msg.status)==1) { //window.location=msg.txt; (can redirect instead) dispBox1(1,msg.txt); $('#dispBox1').toggleClass('noerror'); } else if(parseInt(msg.status)==0) { dispBox1(1,msg.txt); $('#dispBox1').toggleClass('error'); } hideshow('loading',0);}}); } function hideshow(el,act){if(act) $('#'+el).css('visibility','visible');else $('#'+el).css('visibility','hidden');} function dispBox1(act,txt){hideshow('dispBox1',act);if(txt) $('#dispBox1').html(txt);} </script> PHP <?php require('c/cr.php'); require('c/EmailAddressValidator.php'); die('{status:0,txt:"cause i hate you!"}'); $display_msg = ""; if(empty($_POST['regemail'])){ $errorz = "yes"; $display_msg .= "• Email Address left blank.";} else { $email = $_POST['regemail']; $validator = new EmailAddressValidator; if ($validator->check_email_address($email)) { $dbconnReg = mysql_connect($sq_hst, $sq_unme, $sq_pzwrd) or die("Error: " . mysql_error()); mysql_select_db($database) or die("Could not select database"); $stage2check_query = "SELECT COUNT(*) AS stage2check_rows FROM cr_person WHERE email='$email'"; $stage2check_result = mysql_query($stage2check_query) or die('View Count SQL Error, query failed<br>' . mysql_error()); $stage2check_row = mysql_fetch_array($stage2check_result, MYSQL_ASSOC); $stage2check = $stage2check_row['stage2check_rows']; if($stage2check >= "1"){$errorz = "yes"; $display_msg .= "• Email address already registered. Forgot Password?";} else { /*email is good and not found */ } mysql_close($dbconnReg); } else { $errorz = "yes"; $display_msg .= "• Email address is not a valid format."; } } if($errorz == "yes"){ die('{status:0,txt:"' . $display_msg . '"}'); }else{ echo '{status:1,txt:"Sweet!"}'; } ?> HTML <form id="regiForm" action="subreg.php" method="post"> <div id="regsm_wrap"> <div class="regsm_left">Email:</div><div class="regsm_cen"><input type="text" id="regemail" name="regemail" class="field_norm" /> <span id="validEmail"></span></div><div class="regsm_right"><img src="c/question.png" alt="Help" width="16" height="16" /></div> <div class="breakclear"></div> <div class="regsm_left">Username:</div><div class="regsm_cen"><input type="text" id="regname" name="regname" class="field_norm" /> <span id="validName"></span></div><div class="regsm_right"><img src="c/question.png" alt="Help" width="16" height="16" /></div> <div class="breakclear"></div> <div class="regsm_left">Password:</div><div class="regsm_cen"><input type="password" class="field_norm" name="pass" id="pass" /></div><div class="regsm_right"><img src="c/question.png" alt="Help" width="16" height="16" /></div> <div class="breakclear"></div> <div class="regsm_left">Confirm Password:</div><div class="regsm_cen"><input type="password" class="field_norm" name="cpass" id="cpass" /></div><div class="regsm_right"><img src="c/question.png" alt="Help" width="16" height="16" /></div> <div class="breakclear"></div> <div class="regsm_rightR"><input type="submit" value="Register" id="ireg" name="ireg" class="field_butt" /><img id="loading" src="i/ajax-loader.gif" alt="working.." /></div> <div id="dispBox1"> ......</div> </div> </form> Link to comment https://forums.phpfreaks.com/topic/181190-confused-ajax-php-query-worked-then-didnt/ Share on other sites More sharing options...
monkeytooth Posted November 12, 2009 Author Share Posted November 12, 2009 I should mention that this is still working properly to a point, it still does what it needs to minus coming back to the jquery on the main page.. it jumps to the php page and functions properly there. Also the die at the top of the script i should have removed that, that was me testing a thought.. its not normally there.. Link to comment https://forums.phpfreaks.com/topic/181190-confused-ajax-php-query-worked-then-didnt/#findComment-955897 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.