title: Inserting data into MySQL 5.5 using PHP 5.3
body: <p>I am having problem inserting data from a form into MySQL 5.5 database using PHP 5.3
  I am able to insert my data, however I get duplicate insertions.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>&lt;?php
  $host ="localhost";
  $user ="root";
  $password ="password";
  $database ="database1";
  $table ="users";
  
  mysql_connect("$host","$user","$password")or die(mysql_error());
  mysql_select_db("$database")or die(mysql_error());
  $mysql = "INSERT INTO $table (username,password)
            VALUES('$_POST[username]','$_POST[password]')";
  if(!mysql_query($mysql)) die(mysql_error());
  echo"Data inserted";
  mysql_close();
  ?&gt;
  </code></pre>
  
  <p>The error message I get is </p>
  
  <pre><code>"undefined index:username" 
  "undefined index:password"
  </code></pre>
  
  <p>My table fields are three id, username and password.</p>