radar Posted August 2, 2010 Share Posted August 2, 2010 oh also, you're not actually calling the javascript anywhere.. so how do you envision that working? Quote Link to comment Share on other sites More sharing options...
Skewled Posted August 2, 2010 Author Share Posted August 2, 2010 Sorry didn't include that  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>User Registration</title> <script src="scripts/utils.js" type ="text/javascript"></script> <script src="scripts/validation.js" type="text/javascript"></script> </head> <body>  this is all at the very top of my php file, also changed the input field and same results. Quote Link to comment Share on other sites More sharing options...
radar Posted August 2, 2010 Share Posted August 2, 2010 yeah but you have to physically call the checkUsername function from the form through an onClick or an onChange. Quote Link to comment Share on other sites More sharing options...
Skewled Posted August 2, 2010 Author Share Posted August 2, 2010 Isn't that achieved here?  function initPage() {  // Tell the browser what element we need to work with and what function to call  document.getElementById("username").onblur = checkUsername;  document.getElementById("register").disabled = true; } Quote Link to comment Share on other sites More sharing options...
radar Posted August 2, 2010 Share Posted August 2, 2010 yeah but that function is only called once @ page load....  so if you do this:  <input id="register" type="submit" value="Sign Up" name="register" class="signsub" onClick="checkUsername();"/> it should work. Quote Link to comment Share on other sites More sharing options...
Skewled Posted August 2, 2010 Author Share Posted August 2, 2010 It's called at page loading and works to check the username when you leave that input field. The alerts are verifying the information changing when I type new usernames. Â It's just all the usernames come back as denied even when I know it's a good name that isn't registered. Quote Link to comment Share on other sites More sharing options...
radar Posted August 2, 2010 Share Posted August 2, 2010 once it's loaded, it's not checked again because you're not really looping it.. add that onclick into the submit button, and im sure it'll work for you.. Quote Link to comment Share on other sites More sharing options...
radar Posted August 2, 2010 Share Posted August 2, 2010 if it were working, when you put in an alert in the processUsername function or whatever its called.. that alert would have shown, but it didnt. Quote Link to comment Share on other sites More sharing options...
Skewled Posted August 2, 2010 Author Share Posted August 2, 2010 I'm sorry I edited the post where the alerts came back ok, I failed to let you know that. Â I placed all of the alerts and it steps through the program, and they all work. Â But for some reason it won't register any name as new, so it will deny all names. Â That's why I originally believed the issue was with my php script that checks for the username in the database. Quote Link to comment Share on other sites More sharing options...
radar Posted August 2, 2010 Share Posted August 2, 2010 okay, so the many times i asked you to echo $query, what was the result of that?  since thats where the ball is being dropped apparently.  it should pring out something like SELECT COUNT(*) FROM information WHERE username = 'ucntkilme'  if it's working correctly..  if that's not working, take the escape out of the javascript function and try it then.  also take that result from the echo, and try it in phpmyadmin. Quote Link to comment Share on other sites More sharing options...
Skewled Posted August 2, 2010 Author Share Posted August 2, 2010 When I echo the query it displays the username Quote Link to comment Share on other sites More sharing options...
radar Posted August 2, 2010 Share Posted August 2, 2010 yes but how does it display.. thats what i need to see. Quote Link to comment Share on other sites More sharing options...
Skewled Posted August 2, 2010 Author Share Posted August 2, 2010 SELECT username FROM information WHERE username = 'testing'okay  I went back to my php script since they were both doing the same thing. Quote Link to comment Share on other sites More sharing options...
radar Posted August 2, 2010 Share Posted August 2, 2010 okay.... Â have you tried running SELECT username FROM information WHERE username = 'testing' in phpmyadmin to see if it identifies a problem? Quote Link to comment Share on other sites More sharing options...
Skewled Posted August 2, 2010 Author Share Posted August 2, 2010 MySQL returned an empty result set (i.e. zero rows). ( Query took 0.0002 sec ) Â that's the status from phpmyadmin Quote Link to comment Share on other sites More sharing options...
radar Posted August 2, 2010 Share Posted August 2, 2010 okay and it's still not working... Â lets try this... Â after the mysqli_query line add: Â $cnt = mysqli_num_rows($data); echo 'the count is: '.$cnt; Â and lets see what that is getting. Quote Link to comment Share on other sites More sharing options...
Skewled Posted August 2, 2010 Author Share Posted August 2, 2010 if the username isn't taken:  the count is:0okay  if the username is taken:  denied Quote Link to comment Share on other sites More sharing options...
radar Posted August 2, 2010 Share Posted August 2, 2010 and if you alert(request.responseText); in the showUsernameStatus function (right after: if(request.status == 400) { and before the if statement for 'okay' does it show anything? Â i'll be awol for about an hour, im getting off work right now -- i'll check in when i get home. Quote Link to comment Share on other sites More sharing options...
Skewled Posted August 2, 2010 Author Share Posted August 2, 2010 It sends the following alert  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  <html xmlns="http://www.w3.org/1999/xhtml">  <head>  <title>User Registration</title>  <link type="text/css" rel="stylesheet" href="tlstyle.css" />  <script src="scripts/utils.js" type ="text/javascript"></script>  <script src="scripts/validation.js" type="text/javascript"></script>  </head>  <body>  the count is:0okay Quote Link to comment Share on other sites More sharing options...
radar Posted August 2, 2010 Share Posted August 2, 2010 ahh thats where the issue is.. you should have the response be nothing but 'okay' and to achieve that, you either use cases, or use some if statements.. such as: if ($_REQUEST['username'] == '') { // show the form } else { // ajax processing}  or:  $a = isset($_REQUEST['a'])? $_REQUEST['a'] : ''; switch ($a) { default: // show the form break;  case submit: // ajax handling break } Quote Link to comment Share on other sites More sharing options...
radar Posted August 2, 2010 Share Posted August 2, 2010 or... we can get rid of everything but the last 4 letters of the result, and then check if it says 'okay' Quote Link to comment Share on other sites More sharing options...
Skewled Posted August 3, 2010 Author Share Posted August 3, 2010 Had some company stop by, I've never used a case before so I need to look into using that. I'll try to work with refining the if statements I have so far to see if I can get it to work out.  It was saying the count is:0okay because I was echo'ing the query still  I'll post back here either later or tomorrow, thanks again!  Edit: I removed the query echo and either get okay or denied when I access the php script directly.  The alerts are all running fine until It gets to the showUsernameStatus, it's like the ajax script isn't getting the value correct for okay or denied. Quote Link to comment Share on other sites More sharing options...
Skewled Posted August 3, 2010 Author Share Posted August 3, 2010 I used a case to see what the response text would be and it still shows the entire first half of the page then it said okay at the bottom. Quote Link to comment Share on other sites More sharing options...
radar Posted August 3, 2010 Share Posted August 3, 2010 let me do some fiddling around, worst case scenario we'll have to change the target words to something unusual for the script to find. just in case someone puts an input of 'okay' somewhere.  perhaps okay md5 would work. on that.. let me get you the code to alter in both php and javascript. Quote Link to comment Share on other sites More sharing options...
radar Posted August 3, 2010 Share Posted August 3, 2010 in php: Â $ok = md5("okay"); $den = md5("denied"); Â echo $ok; return $ok; Â echo $den; return $den; Â in javascript: Â var hashed = hexMD5('okay'); var response = request.responseText; if(response.search(hashed) != -1) { // do the good thing here } else { // do the bad thing here } Â perhaps that'll work. 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.