469,610 Members | 2,012 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,610 developers. It's quick & easy.

How to prevent multiple entries to db

mmarif4u
Hi everybody,,,
I am facing problem,
Problem is that i have a user with ic already have in my database.
But my query enter another data to db when i try to enter that ic
again.i want that only one ic exist in db.i make query but t only checks the
format like 1234 or 5462313 not 123aa and 123333-12-1234
I want to check the format like 123456-12-1234..
My query is:
Expand|Select|Wrap|Line Numbers
  1. // Check for existing user with the ic number
  2.     $sql = "SELECT COUNT(*) FROM loguser WHERE icnumber = $ic ";
  3.     $result = mysql_query($sql);
  4.     if (!$result) {    
  5.         error('A database error occurred in processing your '.
  6.              'submission.\\nIf this error persists, please '.
  7.               'contact you@example.com.');
  8.     }
  9.  
  10.  
  11.     if (mysql_result($result,0,0)>0)  {
  12.         error('A user already exists with your chosen IC Number.\\n'.
  13.               'Please try your own IC Number.');
  14.     }
  15.     if (preg_match('#^[0-9]{6}-[0-9]{2}-[0-9]{4}$#', $ic))
  16.     {}else{      
  17.     error('IC Number format is not Valid.\\n'.
  18.               'Please try again.');
  19.        }
  20.  
  21.  
please any one has idea about it,,
i think the error is here thats why it didnot check the format entered.
Expand|Select|Wrap|Line Numbers
  1. if (mysql_result($result,0,0)>0)  {
  2.  
Thanks in advance
Jan 6 '07 #1
1 1352
Problem Solved
Jan 6 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Job Lot | last post: by
9 posts views Thread by Catherine Jo Morgan | last post: by
5 posts views Thread by Sammy | last post: by
3 posts views Thread by Bernard Lebel | last post: by
6 posts views Thread by teser3 | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.