any one know how to do this

Started on the old forum in May 2009 · view the original in the archive · old links redirect here

2 replies · 444 views · started 17 years ago · 1 min read

3 participants
jsyguy23 Developer · 134 posts #1

does any one know how to let an email addy only reg with one username like you cant reg the same username 2 times lol i been trying to do it but got no where

Anshul Senior · 296 posts #2

jsyguy23 wrote: does any one know how to let an email addy only reg with one username like you cant reg the same username 2 times lol i been trying to do it but got no where

$usercheck="SELECT*from users where username='$username' or email='$email'";
  $usercheck2=mysql_query($usercheck);
  while ($usercheck3=mysql_fetch_array($usercheck2))
  {
    $valid=0;
  }
  if($valid==0)
  {
    print "That username has been taken or there is already someone registered with that email, please <A href='register.php'>Try to register again</a>.";
  }
djlee Developer · 224 posts #3

better way would be to create a unique key on the email or username field then when u try and dupe a user it wont work, then its just a case of using a bit of code to grab the error number, and if the error code is 1062 (i think would have to check) then its a dupe entry and you can display error accordingly

simply removes the need for that code block, makes the code nicer, allows for multiple things to be checked in one go using error codes and correct setup of tables and more importantly reduces number of queries

Write your reply now; next you create a free account (or sign in) and it is posted right away. Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close