keymistress Posted May 14, 2007 Share Posted May 14, 2007 hello all, i'm a ajax noob so please bear with me. i have a form with a single field to submit an e-mail address. if the e-mail already exists in the database, it will respond "user registered". else, the email will be inserted into the database and respond "you have been registered". the problem now is, the email does get stored in the database but it prompts "user registered" instead of "you have been registered". help! ??? Quote Link to comment Share on other sites More sharing options...
jcombs_31 Posted May 14, 2007 Share Posted May 14, 2007 kinda hard to help without seeing the code. Sounds like you ran the check after the insert Quote Link to comment Share on other sites More sharing options...
keymistress Posted May 14, 2007 Author Share Posted May 14, 2007 i think there's a logic problem... my php file $email=$_GET["email"]; //check if e-mail is already registered if ($row[0] == 0) { //register user $query2 = "INSERT INTO users (username, userPwd, userAccess) VALUES ('$email', '$userPwd', '$userAccess')"; echo $query2; $result2 = mysql_query($query2);*/ echo "An e-mail with your username and password has been sent to the address you have entered."; } else { //e-mail already registered echo "This e-mail has already been registered. Forgot password?"; } my javascript file var xmlHttp function showHint(email) { if (email.length==0) { document.getElementById("userHint").innerHTML=""; return; } xmlHttp=GetXmlHttpObject() if (xmlHttp==null) { alert ("Your browser does not support AJAX!"); return; } var url="getHint.php"; url=url+"?email="+email; url=url+"&sid="+Math.random(); xmlHttp.onreadystatechange=stateChanged; xmlHttp.open("GET",url,true); xmlHttp.send(null); } function stateChanged() { if (xmlHttp.readyState==4) { document.getElementById("userHint").innerHTML=xmlHttp.responseText; } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } and my HTML form <html> <head> <script src="userHint.js"></script> </head> <body> <form> Email: <input type="text" id="email" onkeyup="showHint(this.value)"> </form> <p><div id="userHint"></div></p> </body> </html> Quote Link to comment Share on other sites More sharing options...
sayedsohail Posted May 19, 2007 Share Posted May 19, 2007 i have the same problem? 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.