title: Database connection successful but not able to insert data into database using php
body: <p>I have been struggling for about a week now and still have not got any results. I have read the following questions:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/22022228/unable-to-insert-form-data-in-mysql-database">Unable to insert form data in MySQL database</a></li>
  <li><a href="https://stackoverflow.com/questions/26043628/connection-to-database-seems-successful-but-insert-into-sends-no-data">Connection to database seems successful but INSERT INTO sends no data</a></li>
  <li><a href="https://stackoverflow.com/questions/7393951/php-mysql-not-inserting-into-database">PHP MySQL not inserting into database</a></li>
  <li><a href="https://askubuntu.com/questions/435746/unable-to-send-data-to-mysql-database-it-is-not-taking-by-my-php-code">https://askubuntu.com/questions/435746/unable-to-send-data-to-mysql-database-it-is-not-taking-by-my-php-code</a><br></li>
  </ul>
  
  <p>I tried everything suggested in the above questions' answers. After reviewing my code, if you still think that the above questions' solution relates then please do tell.</p>
  
  <p>My code - <br>
  connect.php - <br></p>
  
  <pre><code>&lt;?php 
  $servername = "localhost";
  $username = "root";
  $password = "";
  $dbname = "practice_user";
  
  // Create connection
  $con = new mysqli($servername, $username, $password, $dbname);
  
  // Check connection
  if ($con-&gt;connect_error) {
      echo "Connection failed: " . $con-&gt;connect_error;
  } 
   else {
     echo "Success"; 
  }
  
  //Insert data into database
  $sql = "INSERT INTO simple_login (name,email) VALUES('{$mysqli-&gt;real_escape_string($_POST['name'])}','{$mysqli-&gt;real_escape_string($_POST['email'])}')";
  
  
  $insert = $mysqli-&gt;query($sql);
  
  if(!$insert)
  {
     echo $mysqli-&gt;error;
  }
  
  
  
  $mysqli-&gt;close();
  </code></pre>
  
  <p><br>
  register.html - </p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;TODO supply a title&lt;/title&gt;
          &lt;meta charset="UTF-8"&gt;
          &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
      &lt;/head&gt;
      &lt;body&gt;
         &lt;form action="connect.php" method="post"&gt;
          Name: &lt;input type="text" name="name"&gt;&lt;br&gt;
          E-mail: &lt;input type="text" name="email"&gt;&lt;br&gt;
          &lt;input type="submit" value="Submit" name="submit"&gt;
         &lt;/form&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><br>As usual I am getting a "Successful" message for connection. Also it is not outputting any error message(if I have not appropriately tried to output insertion error in the given code, please do tell in the comments).</p>
  
  <p>Thank you in anticipation.</p>