title: prevent duplicate enteries sql php
body: <p>I am working on a database system and i am trying avoid duplicate entries for email and username. i have tried but it is still rejects but unable to see exactly what is being rejected. 
  can someone tell explain where i am wrong?</p>
  
  <pre><code>if(isset($_POST['submit'])){
  $username = $_POST['username'];
  $password = $_POST['password'];
  $email = $_POST['email'];
  
   $sql="INSERT into users (username,password,email) VALUES('$username','$password','$email')";
  
   $result = mysql_query("INSERT INTO users VALUES ('duplicate')");
  
   if (!$result) {
  echo "Enter a different value";
   } else {
  echo "Save successful.";
  
  }
  }
  </code></pre>