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? Link to comment https://forums.phpfreaks.com/topic/209600-id-like-someone-to-verify-my-code/page/2/#findComment-1094332 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. Link to comment https://forums.phpfreaks.com/topic/209600-id-like-someone-to-verify-my-code/page/2/#findComment-1094334 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. Link to comment https://forums.phpfreaks.com/topic/209600-id-like-someone-to-verify-my-code/page/2/#findComment-1094335 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; } Link to comment https://forums.phpfreaks.com/topic/209600-id-like-someone-to-verify-my-code/page/2/#findComment-1094337 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. Link to comment https://forums.phpfreaks.com/topic/209600-id-like-someone-to-verify-my-code/page/2/#findComment-1094339 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. Link to comment https://forums.phpfreaks.com/topic/209600-id-like-someone-to-verify-my-code/page/2/#findComment-1094343 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.. Link to comment https://forums.phpfreaks.com/topic/209600-id-like-someone-to-verify-my-code/page/2/#findComment-1094344 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. Link to comment https://forums.phpfreaks.com/topic/209600-id-like-someone-to-verify-my-code/page/2/#findComment-1094345 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. Link to comment https://forums.phpfreaks.com/topic/209600-id-like-someone-to-verify-my-code/page/2/#findComment-1094347 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. Link to comment https://forums.phpfreaks.com/topic/209600-id-like-someone-to-verify-my-code/page/2/#findComment-1094348 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 Link to comment https://forums.phpfreaks.com/topic/209600-id-like-someone-to-verify-my-code/page/2/#findComment-1094352 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. Link to comment https://forums.phpfreaks.com/topic/209600-id-like-someone-to-verify-my-code/page/2/#findComment-1094353 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. Link to comment https://forums.phpfreaks.com/topic/209600-id-like-someone-to-verify-my-code/page/2/#findComment-1094354 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? Link to comment https://forums.phpfreaks.com/topic/209600-id-like-someone-to-verify-my-code/page/2/#findComment-1094356 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 Link to comment https://forums.phpfreaks.com/topic/209600-id-like-someone-to-verify-my-code/page/2/#findComment-1094357 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. Link to comment https://forums.phpfreaks.com/topic/209600-id-like-someone-to-verify-my-code/page/2/#findComment-1094358 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 Link to comment https://forums.phpfreaks.com/topic/209600-id-like-someone-to-verify-my-code/page/2/#findComment-1094360 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. Link to comment https://forums.phpfreaks.com/topic/209600-id-like-someone-to-verify-my-code/page/2/#findComment-1094363 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 Link to comment https://forums.phpfreaks.com/topic/209600-id-like-someone-to-verify-my-code/page/2/#findComment-1094367 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 } Link to comment https://forums.phpfreaks.com/topic/209600-id-like-someone-to-verify-my-code/page/2/#findComment-1094378 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' Link to comment https://forums.phpfreaks.com/topic/209600-id-like-someone-to-verify-my-code/page/2/#findComment-1094379 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. Link to comment https://forums.phpfreaks.com/topic/209600-id-like-someone-to-verify-my-code/page/2/#findComment-1094402 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. Link to comment https://forums.phpfreaks.com/topic/209600-id-like-someone-to-verify-my-code/page/2/#findComment-1094607 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. Link to comment https://forums.phpfreaks.com/topic/209600-id-like-someone-to-verify-my-code/page/2/#findComment-1094638 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. Link to comment https://forums.phpfreaks.com/topic/209600-id-like-someone-to-verify-my-code/page/2/#findComment-1094640 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.