Jump to content

Register page Help.


Hunter94

Recommended Posts

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]

Link to comment
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.