title: How to give validation of mobile number which is already in a database?
body: <p>I have driver_info table, In that i want to insert a record of various drivers of parameters driver_name,vehicle_no,license_no,mob_no,photo etc. respectively, but i have to avoid duplication of mobile number, I am trying below code for checking duplication of mobile number but it doesn't work and gives "successfully registered!!!" message.</p>
  
  <pre><code>if(isset($_POST['submit']))
  {
  
  $m_no = mysql_real_escape_string( $_POST['m_no']);
  $query1 = "SELECT mob_no FROM driver_info WHERE mob_no='$m_no'";
      $result1 = mysql_query($query1) or die(mysql_error());
  
      if (mysql_num_rows($result1)){
          echo '&lt;script language="javascript"&gt;';
      echo 'alert("Mobile_No is Already Exist...."); location.href="signup.php"';
      echo '&lt;/script&gt;';
      }
      else{
  
  $v = $_POST['n'];   
  $name = $_POST['nme'];
  $v_no = $_POST['v_no'];
  $l_no = $_POST['l_no'];
  $m_no = $_POST['m_no'];
  $photo = $_FILES['txtphoto']['name'];
  $stat = $_POST['stat'];
  
  $query ="INSERT INTO
  driver_info(driver_name,vehicle_no,license_no,mob_no,photo,status,seller_id)
  VALUES('$name','$v_no','$l_no','$m_no','$photo','$stat','$v')";
  
  $result = mysql_query($query);
  
  copy($_FILES['txtphoto']['tmp_name'],"Picture/".$photo);
  if($result==1)
      {
          echo '&lt;script language="javascript"&gt;';
      echo 'alert("successfully registered!!!"); location.href="index.php"';
      echo '&lt;/script&gt;';
      }
      else
      {
        echo '&lt;script language="javascript"&gt;';
      echo 'alert("Something Went Wrong!!! :("); location.href="index.php"';
      echo '&lt;/script&gt;';
      }
      //mysql_close(@mysql_connect);
  }   
  }
  ?&gt;
  </code></pre>