title: How to check if data already exists in MySQL with PHP
body: <p>This is my php code. How to check if this 3 parameters (user,agwera,vis) exist in MySQL with PHP? And if already exist don't add a second time. + want <code>echo "Already in Exists&lt;br/&gt;";</code></p>
  
  <pre><code>    &lt;?
  sleep(10);
  define ('DBHOST', 'yyy');
  define ('DBNAME', 'xxxx');
  define ('DBUSER', 'xxxx');
  define ('DBPASS', 'xxxxx');
  
  mysql_pconnect(DBHOST, DBUSER, DBPASS) or die('DB');
  mysql_select_db(DBNAME) or die ('USER');
  mysql_query('SET NAMES utf8');
  
  header('Content-Type: text/html; charset=utf-8');
  error_reporting (0);
  $act = isset($_GET['act']) ? $_GET['act'] : '';
  switch($act)
  {
  case 'send':
  $destination = $_POST['adress']; 
  $signature = $_POST['text']; 
  $text = "$signature ";
  
  
  
  if (empty($_POST["text"])  or strlen($_POST["text"])==0){
  
  @header("location:error5.php");
  break;
  
  }
  
  $str = $_POST['text']; 
  if (strlen($str)&gt;160){
  @header("location:error4.php");
  break;
  
  }
  
  if (!preg_match('/^[0-9]{9}$/',$destination))
  {
  @header("location:error1.php");
  break;
  }
  
  $str2 = $_POST['sender'];
  if (strlen($str2)&gt;11){
  @header("location:error2.php");
  break;
  }
  
  if (empty($_POST["sender"])  or strlen($_POST["sender"])==0){
  
  @header("location:error3.php");
  break;
  
  }
  
  else
  {
  
      $password = 'zzzzzz';
      $destination = $_POST['adress']; 
    $nomeri = "995$destination";
      $nomeri2 = $_POST['sender']; 
      $source = $nomeri2;
      $signature = $_POST['text']; 
      $text = "$signature "; 
  
      $content = 
                  'key='.rawurlencode($password). 
                  '&amp;destination='.rawurlencode($nomeri). 
                  '&amp;sender='.rawurlencode($source). 
                  '&amp;content='.rawurlencode($text); 
  
      $a = file_get_contents('http://example.com/api/send.aspx?'.$content); 
  
  @header("location:ok.php");
  
  mysql_query("INSERT `gagzavnili` SET
                        `user`        =   '".$source."',
                        `agwera`      =   '".$text."',
                        `vis`     =   '".$destination."',
                        `time_upload` =   '".time()."',
                        `time`        =   '".time()."'") or die(mysql_error());
                         $file_id = mysql_insert_id();
  
  
  
  }
  }
  ?&gt;
  </code></pre>