title: What is the correct/right code for uploading or inserting values from input html tag into mysql using php?
body: <p>What is the correct/right code for uploading or inserting values from input html tag into mysql using php?</p>
  
  <p>I have php file and html file, but when I try to click the submit button, it only display the php file. My phpMyAdmin connected to my web host, while the html page is not</p>
  
  <p>Html code:</p>
  
  <pre><code>&lt;form action="add.php" method="post" enctype="multipart/form-data"&gt;
      &lt;input type="text" name="contract_num"&gt;&lt;br&gt;
      &lt;input type="text" name="random_file"&gt;&lt;br&gt;
      &lt;input type="submit" value="Upload file"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>PHP:</p>
  
  <pre><code>&lt;?
   $contract_num=$_POST['contract_num'];
   $random_file=$_POST['random_file'];
  mysql_connect("your.hostaddress.com", "username", "password")
  or die(mysql_error());
  mysql_select_db("contract")
  or die(mysql_error());
  mysql_query("INSERT INTO `contract` VALUES ('$contract_num', '$random_file')");
  Print "Your information has been successfully added to the database."; 
  ?&gt;
  </code></pre>