Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_POST["submit"]))
- {
- $host="localhost";
- $db_user="root";
- $db_password="";
- $db='tabel_cart';
- $conn=mysql_connect($host,$db_user,$db_password) or die (mysql_error());
- mysql_select_db($db) or die (mysql_error());
- echo $filename=$_FILES["file"]["name"];
- $ext=substr($filename,strrpos($filename,"."),(strlen($filename)-strrpos($filename,".")));
- if($ext==".csv")
- {
- $file = fopen($_FILES["file"]["tmp_name"], "r");
- $now = date('d-m-Y g:i:s A');
- $count = 0;
- while (($ImpData = fgetcsv($file, 10000, ",")) !== FALSE)
- {
- $count++;
- if($count>1){
- $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]')";
- mysql_query($sql);
- }
- }
- fclose($file);
- echo ":) Success: File Imported.";
- }
- else {
- echo ":( Invalid Format: Please Upload CSV extension File";
- }
- }
- ?>
Add Comment
Please, Sign In to add comment