Guest User

Untitled

a guest
Oct 19th, 2017
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. <?php
  2.  
  3. if(isset($_POST["submit"]))
  4. {
  5. $host="localhost";
  6. $db_user="root";
  7. $db_password="";
  8. $db='tabel_cart';
  9. $conn=mysql_connect($host,$db_user,$db_password) or die (mysql_error());
  10. mysql_select_db($db) or die (mysql_error());
  11.  
  12. echo $filename=$_FILES["file"]["name"];
  13. $ext=substr($filename,strrpos($filename,"."),(strlen($filename)-strrpos($filename,".")));
  14.  
  15. if($ext==".csv")
  16. {
  17. $file = fopen($_FILES["file"]["tmp_name"], "r");
  18. $now = date('d-m-Y g:i:s A');
  19. $count = 0;
  20.  
  21. while (($ImpData = fgetcsv($file, 10000, ",")) !== FALSE)
  22. {
  23. $count++;
  24. if($count>1){
  25. $sql = "INSERT into off_cart_table1 (imp_date_time, off_shop_cart_num, off_shop_cart_due_month, off_shop_cart_type, off_shop_cart_title, off_shop_cart_fname, off_shop_cart_lname, off_shop_cart_mobile, off_shop_cart_email, off_shop_cart_address1, off_shop_cart_address2, off_shop_cart_address3, off_shop_cart_city, off_shop_cart_state, off_shop_cart_country, off_shop_cart_pincode) values( '$now','$ImpData[0]', '$ImpData[1]', '$ImpData[2]', '$ImpData[3]', '$ImpData[4]', '$ImpData[5]', '$ImpData[6]', '$ImpData[7]', '$ImpData[8]', '$ImpData[9]', '$ImpData[10]', '$ImpData[11]', '$ImpData[12]', '$ImpData[13]', '$ImpData[14]')";
  26. mysql_query($sql);
  27. }
  28. }
  29.  
  30. fclose($file);
  31. echo ":) Success: File Imported.";
  32. }
  33. else {
  34. echo ":( Invalid Format: Please Upload CSV extension File";
  35. }
  36. }
  37. ?>
Add Comment
Please, Sign In to add comment