title: How to insert a record in MySQL with PHP with an HTML form
body: <p>I have created a form in html and I would like that the dataentered in the form is sent to a mysql database in XAMMP. I created the database, the table and the connectivity.php file that manages the connection to the database and data entry, but when I try I get the following error:</p>
  
  <p>"Fatal error: Uncaught Error: Call to undefined function mysql_connect() in C:\xampp\htdocs\example\connectivity.php:8 Stack trace: #0 {main} thrown in C:\xampp\htdocs\example\connectivity.php on line 8"</p>
  
  <p>I post all the code that I wrote. Does anyone know where I'm wrong?</p>
  
  <p>here is the form index.html</p>
  
  <pre><code>    &lt;!DOCTYPE HTML&gt;
  &lt;html&gt;
  
  &lt;head&gt;
      &lt;title&gt;Contact Us&lt;/title&gt;
      &lt;link rel="stylesheet" type="text/css" href="style.css"&gt;
  
      &lt;?php include("connectivity.php"); ?&gt;
  
  &lt;/head&gt;
  
  &lt;body&gt;
      &lt;div id="contact"&gt;
          &lt;h3&gt;Contact Us For Any Query&lt;/h3&gt;
          &lt;form method="POST" action="connectivity.php"&gt;
              Name
              &lt;br&gt;
              &lt;input type="text" name="name"&gt;
              &lt;br&gt; Email
              &lt;br&gt;
              &lt;input type="text" name="email"&gt;
              &lt;br&gt; Message
              &lt;br&gt;
              &lt;textarea rows="10" cols="50" maxlength="100" name="message"&gt;&lt;/textarea&gt;
              &lt;br&gt;
              &lt;input type="submit" value="Send Message"&gt;
          &lt;/form&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>Then the code used to define database and the table:</p>
  
  <pre><code>CREATE DATABASE practice;
  USE practice;
  
  CREATE TABLE contact
  (
  contactID INT(9) NOT NULL auto_increment,
  contactName VARCHAR(40) NOT NULL,
  contactEmail VARCHAR(40) NOT NULL,
  message VARCHAR(250) NOT NULL,
  PRIMARY KEY(contactID)
  );
  </code></pre>
  
  <p>Finally the connectivity.php file:</p>
  
  <pre><code>&lt;?php
  //connecting to the database
  define('DB_HOST', 'localhost');
  define('DB_NAME', 'practice');
  define('DB_USER','root');
  define('DB_PASSWORD','');
  
  $con=mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) or die("Failed to connect to MySQL: " . mysql_error());
  $db=mysql_select_db(DB_NAME,$con) or die("Failed to connect to MySQL: " . mysql_error());
  //inserting Record to the database
  $name = $_POST['name'];
  $email = $_POST['email'];
  $message =  $_POST['message'];
  
  $query = "INSERT INTO contact(contactName,contactEmail,message)VALUES('$name','$email','$message')";
  $result = mysql_query($query);
  if($result)
      {
          echo "Successfully updated database";
      }
      else
      {
       die('Error: '.mysql_error($con));
      }
      mysql_close($con);
  ?&gt;
  </code></pre>
  
  <p>P.S: I installed the latest version of XAMMP (5.6.15)</p>
  
  <p>$con=mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD,##TABLE NAME##) or die("Failed to connect to MySQL: " . mysql_error());</p>
  
  <p>$query = "INSERT INTO contact(contactName,contactEmail,message)VALUES('$name','$email','$message')";
  $result = mysqli_query($con,$query);</p>