...We are here to say something...

How to avoid duplicate data insertion using php and MySql

if(isset($_POST["Register"]))
{
mysql_connect("localhost","root","");
mysql_select_db("demo");
$first_name = $_POST["emp_first_name"];
$resultset_1 = mysql_query("select * from employee where emp_first_name=.$first_name. ") or die(mysql_error());
$count = mysql_num_rows($resultset_1);
if($count == 0)
{
$ resultset_2 = mysql_query("INSERT INTO demo.employee VALUES (.$first_name.)") or
die(mysql_error());
}else{
echo The user is already present in the employee table ;
}
}
?>




First Name:



By :Md. Masud Ali Reza

Email : reez
Date/time : 31/01/2019

  ID : 1
  Name : N Sultana
  Email : nsu@yahoo.com
  Answer : Thank you very much, it is very helpful.
  Date/Time : 01/02/19 08:58:24

  ID : 2
  Name : AHM Mostafa Kamal
  Email : abuhmmk@yahoo.com
  Answer : Bujlamna ....................
  Date/Time : 04/02/19 09:28:31

  ID : 3
  Name :
  Email :
  Answer :
  Date/Time : 01/11/19 08:11:23

  ID : 4
  Name :
  Email :
  Answer :
  Date/Time : 25/11/19 08:01:55

  ID : 5
  Name :
  Email :
  Answer :
  Date/Time : 24/01/20 08:04:18

  ID : 6
  Name :
  Email :
  Answer :
  Date/Time : 24/03/20 08:09:55


Name :
Email :
Answer :
 

Login