title: How to detect that username already use in the database
body: <pre><code>&lt;?php
  
  if(isset($_POST["Add"]))    
  {
  
  $name=$_POST["Emp_Username"];
  $pass=$_POST["Emp_Password"];
  $fname=$_POST["Emp_Fname"];
  $lname=$_POST["Emp_Lname"];
  $hph=$_POST["ContactNo_Home"];
  $hp=$_POST["ContactNo_HP"];
  $mail=$_POST["Emp_Email"];
  $add=$_POST["Emp_Address"];
  $age=$_POST["Emp_Age"];
  $pos=$_POST["Position"];
  $dept=$_POST["Dept_ID"];
  
  mysql_query("
      insert into employee(Dept_ID, Emp_Address, Emp_Age, 
      Position, &gt;Emp_Username, Emp_Password, Emp_Fname, Emp_Lname, 
      ContactNo_Home, ContactNo_HP, Emp_Email) 
      &gt;values('$dept','$add','$age','$pos','$name','$pass','$fname',
      '$lname','$hph','$hp','$mail'&gt;)
     ");
  
  ?&gt;    
  
  &lt;script type="text/javascript"&gt;
  alert("Record saved.");    
  &lt;/script&gt; 
  
  &lt;?php } ?&gt;
  </code></pre>