Jump to content

php script for checking ids


Recommended Posts

Hi. Im making a gaming competitive site. Anyway in profile section I have it where they can add their ids. I wanted a code to prevent people from adding same id as someone elses.Ive used code below

 

}

 

if(mysql_num_rows(mysql_query("SELECT id FROM members WHERE icq='$member[icq]'"))){

 

$mes.="Cod5 id is already in use.<br />";

}

 

This code works for what i want however if you go into ur profile and dont edit anything or edit a completely different id and click update account it picks up that the cod5 id is already in use even though you did not change it and no one but you have it. The code is reading its own users id so it thinks your adding a duplicate id. What do i need to add to that code to have it check all ids except your own(user logged in at the time)? Thanks a lot for all your help.. Im new to php.

Link to comment
Share on other sites

ok so code would be...

 

}

 

if(mysql_num_rows(mysql_query("SELECT id FROM members WHERE icq='$member[icq]' AND id != $userid"))){

 

$mes.="Cod5 id is already in use.<br />";

}

 

??  But the id for current user would be different depending on whos logged into my site at the time.So would this still work??

Link to comment
Share on other sites

replace $userid with whatever variable holds the id of the user that is currently logged in.  This tells the query not to look at the current user's record, we expect the icq to match on that record and we don't care that it does because it is the same record we are about to update.

Link to comment
Share on other sites

  • 1 month later...
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.