I have written a long program. Im just sharing here some lines to understand a concept which is my issue here. I want to check if the previous data is equal to the newly entered, if it is, then an error should occur that the data is already entered, without storing again in db. Following code is running but it duplicates data. It is not quite good. may you please check where I am wrong. thanks
Database Name Booking:
Table Name data:
Name: John, Anjel, Smith, David
CNIC: 33, 46, 33, 91
//// storing data in database from html form fields
<?php
$emp_name = addslashes($_POST['emp_name']);
$emp_cnic = addslashes($_POST['emp_cnic']);
?>
//// Selecting CNIC that is duplicated (already existed) on a new form submission
$already = mysql_query("SELECT CNIC FROM data WHERE CNIC = '$emp_cnic'");
//Dieing script without storing the data if it already exists.
if($already){
die('Sorry! you are already registered. For any query, contact the administrator. ');