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="#">[email protected]</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="#">[email protected]</a> | </div> </div>[/b] Link to comment https://forums.phpfreaks.com/topic/140711-register-page-help/ 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. Link to comment https://forums.phpfreaks.com/topic/140711-register-page-help/#findComment-736467 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? Link to comment https://forums.phpfreaks.com/topic/140711-register-page-help/#findComment-736469 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. Link to comment https://forums.phpfreaks.com/topic/140711-register-page-help/#findComment-736471 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.