Hunter94 Posted January 13, 2009 Share Posted January 13, 2009 Look at the 2nd code I posted. When I try to register an account that already exists it cuts off this part of the HTML Code(The First Code I posted). Does any one know how to make it not cut off that part? </div> [b]</div> <div id="footer"> copyright © 2009 Hunter Davis | <a href="#">the1_hunter@hotmail.com</a> | </div> </div>[/b] [b] { exit("$frmName exists please choose another username"); } If (MySQL_DB_Query("coproj", "INSERT INTO accounts SET AccountID='".MySQL_Real_Escape_String($_POST["name"], $Server)."', LogonType='2', Status='6'")) { Echo "Registration successfully!<br>The Password will be the one which you type at your first Login! Have fun!"; } Else { Echo "Registration failed!"; } } Else { ?> <form method=post action=""> <table style="position: absolute; top: 50%; left: 36%; width: 300px; height: 40px; margin-left: -150px; margin-top: -50px;"> <tr> <td> Account Login: </td> <td> <input type=text name="name" maxlength=30 style="width: 100%;" /> </td> </tr> <tr> <td colspan=2><input type=submit name="submit" value="Submit" style="width: 100%;" /></td> </tr> </table> </form> <?php } } Else { Echo "Connection to the Database failed."; } ?> </div> </div> <div id="footer"> copyright © 2009 Hunter Davis | <a href="#">the1_hunter@hotmail.com</a> | </div> </div>[/b] Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted January 13, 2009 Share Posted January 13, 2009 The problem is that you exit the script execution if there's a row found here: if(mysql_num_rows($sQuery) > 0 ) [b] { exit("$frmName exists please choose another username"); } When you exit, the script stops completely. Nothing else will be executed or output to the screen. Your best bet is probably to rethink your logic a touch. Quote Link to comment Share on other sites More sharing options...
Hunter94 Posted January 13, 2009 Author Share Posted January 13, 2009 The problem is that you exit the script execution if there's a row found here: if(mysql_num_rows($sQuery) > 0 ) [b] { exit("$frmName exists please choose another username"); } When you exit, the script stops completely. Nothing else will be executed or output to the screen. Your best bet is probably to rethink your logic a touch. Iv, tried every thing. It either messes the whole page up or it gives me a error. Not sure what to do. Is there a Code I could put in there to make it continue the page? Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted January 13, 2009 Share Posted January 13, 2009 As a rough skeleton, you want to do something like this: $sql = "SELECT COUNT(*) FROM yourtable WHERE username='$username'"; $result = mysql_query($sql); if(mysql_result($result,0)==0){ //username doesn't exist //insert username into database //display successful registration message }else{ //tell user that username already exists } //rest of html is shown here Notice that i don't exit at any point. I simply use an if-else statement to control the flow so that the username is only inserted if it doesn't exist. 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.