title: uploading excel/CSV file data into database
body: <p>I have to write a code were i need to import the email ids of people with their names which will be on a excel sheet into the database, but the issue which am facing is, it is inserting blank data into the database,please help, am new to this concept,pardon me if i went wrong somewhere.</p>
  
  <p><strong>DB Structure</strong><a href="https://i.stack.imgur.com/y2lX2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/y2lX2.png" alt="enter image description here"></a></p>
  
  <p><strong>import.php</strong></p>
  
  <pre><code>&lt;form enctype="multipart/form-data" method="post" role="form"&gt;
      &lt;div class="form-group"&gt;
          &lt;label for="exampleInputFile"&gt;File Upload&lt;/label&gt;
          &lt;input type="file" name="file" id="file" size="200" required=""&gt;
      &lt;/div&gt;
      &lt;button type="submit" class="btn btn-default" name="Import" value="Import"&gt;Upload&lt;/button&gt;
  &lt;/form&gt;
      &lt;?php 
  if(isset($_POST["Import"]))
  {
      $con = mysqli_connect("localhost","***","***","***");
      echo $filename=$_FILES["file"]["tmp_name"];
      if($_FILES["file"]["size"] &gt; 0)
      {
          $file = fopen($filename, "r");
                    $count = 0;
                    while (($emapData = fgetcsv($file, 10000, ",")) !== FALSE)
                               {
                                $count++;
                          if($count&gt;1){
                                 $query = "INSERT INTO import_email (via, vault_no, name, email, created_at) VALUES ('".$_SESSION['via']."', '".$_SESSION['vault_no']."', '$name[0]', '$email[1]', NOW())";
                                             mysqli_query($con, $query);
                          }
                      }
                   fclose($file);
              echo 'CSV File has been successfully Imported';
          //header('Location: profile_1.php');
      }else{
          echo 'Invalid File:Please Upload CSV File';
      }
  }
  ?&gt;
  </code></pre>
  
  <p><strong>EXCEL Structure(.csv format)</strong>
  <a href="https://i.stack.imgur.com/7Coy5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7Coy5.png" alt="enter image description here"></a></p>
  
  <p>Thank you.</p>