472,125 Members | 1,381 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,125 software developers and data experts.

How to prevent multiple entries to db

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.     }
  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.        }
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)  {
Thanks in advance
Jan 6 '07 #1
1 1390
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

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.