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
- // Check for existing user with the ic number
- $sql = "SELECT COUNT(*) FROM loguser WHERE icnumber = $ic ";
- $result = mysql_query($sql);
- if (!$result) {
- error('A database error occurred in processing your '.
- 'submission.\\nIf this error persists, please '.
- 'contact you@example.com.');
- }
- if (mysql_result($result,0,0)>0) {
- error('A user already exists with your chosen IC Number.\\n'.
- 'Please try your own IC Number.');
- }
- if (preg_match('#^[0-9]{6}-[0-9]{2}-[0-9]{4}$#', $ic))
- {}else{
- error('IC Number format is not Valid.\\n'.
- 'Please try again.');
- }
i think the error is here thats why it didnot check the format entered.
Expand|Select|Wrap|Line Numbers
- if (mysql_result($result,0,0)>0) {