Question: I have a field area\_code in mysql table by php form. I need the validation & alert when typing the same area code which is already entered and stored in database.

Answer: 
The best way you do is to define a `UNIQUE` constraint on field `area_code` on the table.

```
ALTER TABLE tableName ADD CONSTRAINT tb_UQ UNIQUE (area_code)

```

if the code was executed and successful, the server will generate an error if you try to enter `area_code` that is already present on the table.
You could make a SELECT count statement and check if the returned rows. If so, it means that the record already exists.

```
SELECT COUNT(id) AS count FROM area_codes WHERE area_code = 'ABC'

```

If returned row is greater than 1, than the record you are trying to insert already exists.