Jump to content

Search the Community

Showing results for tags 'php to csv'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. I have a from which i am trying to send it via mail with form data as csv the form also has a three file felds too, i want to add the csv file and the other files as a zip and send it to users email. so far i have tried to do something like this. include('connect.php'); session_start(); $Ptan= $Pcomp= $frm1= $frm= $fiefrmincom= $fileopt= $filesup= $txtChCnt= $txtMdIns= $filesup4= $filfrmoth= $filoatt=$frmPas1= $frmPas= $fiefrmincomPas= $fileoptPas= $filesupPas1= $filesupPas2= $filesupPas3= $filesupPas4= $filfrmothPas= $filoattPas= $fileopt=$filesupPas=''; $supdoc=$txtfrmcnt =0; $frmcnt=0; $uploadpath='uploads'; $file_folder = "uploads/"; // folder to load files $zip = new ZipArchive(); // Load zip library $zip_name = time().".zip"; if(isset($_FILES["txtfrm"]["tmp_name"])&& $_FILES["txtfrm"]["tmp_name"]!='') { $fname=explode('.', $_FILES["txtfrm"]["name"]); $fn=$fname[0].$_REQUEST['txtpan'].'.'.$fname[1]; move_uploaded_file($_FILES["txtfrm"]["tmp_name"], $uploadpath.'/'.$fn); $frm=$uploadpath.'/'.$fn; $frmpas=$_REQUEST["txtfrmPassword"]; $frmcnt=1; } if($zip->open($zip_name, ZIPARCHIVE::CREATE)!==TRUE){ // Opening zip file to load files $error .= "* Sorry ZIP creation failed at this time<br/>"; } else { $zip->addFile($file_folder.$fn); // Adding files into zip } $zip->close(); if(isset($_REQUEST["txtaddInv"])) { $txtMdIns=$_REQUEST["txtaddInv"]; // $supdoc++; } if(isset($_REQUEST["txtChCnt"])) { $txtChCnt=$_REQUEST["txtChCnt"]; // $supdoc++; } if(isset($_REQUEST["txtMdIns"])) { $txtMdIns=$_REQUEST["txtMdIns"]; // $supdoc++; } //exit(0); $fileoptcnt=0; if(isset($_FILES["fileopt"]["tmp_name"]) && $_FILES["fileopt"]["tmp_name"]!='') { //mkdir("uploads/fileopt_".$_REQUEST['txtpan'], 0777); //$uploadpath=$uploadpath."/fileopt_".$_REQUEST['txtpan']; $fname=explode('.', $_FILES["fileopt"]["name"]); $fn=$fname[0].$_REQUEST['txtpan'].'.'.$fname[1]; move_uploaded_file($_FILES["fileopt"]["tmp_name"], $uploadpath.'/'.$fn); $fileopt=$uploadpath.'/'.$fn; $fileoptPas=$_REQUEST["fileoptPassword"]; $fileoptcnt=1; } if($zip->open($zip_name, ZIPARCHIVE::CREATE)!==TRUE){ // Opening zip file to load files $error .= "* Sorry ZIP creation failed at this time<br/>"; } else { $zip->addFile($file_folder.$fn); // Adding files into zip } $zip->close(); $filmcnt=0;$txtfrm=0; if(isset($_FILES["filfrmoth"]["tmp_name"]) && $_FILES["filfrmoth"]["tmp_name"]!='') { // mkdir("uploads/filfrmoth_".$_REQUEST['txtpan'], 0777); // $uploadpath=$uploadpath."/filfrmoth_".$_REQUEST['txtpan']; $fname=explode('.', $_FILES["filfrmoth"]["name"]); $fn=$fname[0].$_REQUEST['txtpan'].'.'.$fname[1]; move_uploaded_file($_FILES["filfrmoth"]["tmp_name"], $uploadpath.'/'. $fn); $filfrmoth=$uploadpath.'/'.$fn; $filfrmothPas=$_REQUEST["filfrmothPassword"]; $filmcnt=1; } if($zip->open($zip_name, ZIPARCHIVE::CREATE)!==TRUE){ // Opening zip file to load files $error .= "* Sorry ZIP creation failed at this time<br/>"; } else { $zip->addFile($file_folder.$fn); // Adding files into zip } $zip->close(); $fiefrmincomCnt=0; if(isset($_FILES["fiefrmincom"]["tmp_name"]) && $_FILES["fiefrmincom"]["tmp_name"]!='') { // mkdir("uploads/fiefrmincom_".$_REQUEST['txtpan'], 0777); //$uploadpath=$uploadpath."/fiefrmincom_".$_REQUEST['txtpan']; $fname=explode('.', $_FILES["fiefrmincom"]["name"]); $fn=$fname[0].$_REQUEST['txtpan'].'.'.$fname[1]; move_uploaded_file($_FILES["fiefrmincom"]["tmp_name"], $uploadpath.'/'. $fn); $fiefrmincom=$uploadpath.'/'.$fn; $fiefrmincomPas=$_REQUEST["fiefrmincomPassword"]; $fiefrmincomCnt=1; } if($zip->open($zip_name, ZIPARCHIVE::CREATE)!==TRUE){ // Opening zip file to load files $error .= "* Sorry ZIP creation failed at this time<br/>"; } else { $zip->addFile($file_folder.$fn); // Adding files into zip } $zip->close(); $filoattcnt=0; if(isset($_FILES["filoatt"]["tmp_name"]) && $_FILES["filoatt"]["tmp_name"]!='') { //mkdir("uploads/filoatt_".$_REQUEST['txtpan'], 0777); // $uploadpath=$uploadpath."/filoatt_".$_REQUEST['txtpan']; $fname=explode('.', $_FILES["filoatt"]["name"]); $fn=$fname[0].$_REQUEST['txtpan'].'.'.$fname[1]; move_uploaded_file($_FILES["filoatt"]["tmp_name"], $uploadpath.'/'.$fn); $filoatt=$uploadpath.'/'.$fn; $filoattPas=$_REQUEST["filoattPassword"]; $filoattcnt=1; } $pecount=$_REQUEST['txtpemp']; for($i=1;$i<=$pecount;$i++){ if(isset($_REQUEST['txtpcmp'.$i])) { $Pcomp=$Pcomp.','.$_REQUEST['txtpcmp'.$i]; $Ptan=$Ptan.','.$_REQUEST['txtptan'.$i]; if(isset($_FILES["txtfrm_".$i]["tmp_name"]) && $_FILES["txtfrm_".$i] ["tmp_name"]!='') { move_uploaded_file($_FILES["txtfrm_".$i]["tmp_name"], $uploadpath.'/'. $_FILES["txtfrm_".$i]["name"]); $frm1= $frm1.','.$uploadpath.'/'.$_FILES["txtfrm_".$i]["name"]; $frmPas1= $frmPas1.','.$_REQUEST["txtfrmpswd".$i]; $txtfrmcnt++; } } if($zip->open($zip_name, ZIPARCHIVE::CREATE)!==TRUE){ // Opening zip file to load files $error .= "* Sorry ZIP creation failed at this time<br/>"; } else { $zip->addFile($file_folder.$_FILES["txtfrm_".$i]["name"]); // Adding files into zip } $zip->close(); } if(isset($_REQUEST['Sub'])) { $Smail=$_REQUEST['Sub']; $Smail1=$_REQUEST['Sub'].'@itfiling.in'; } else { $Smail='mylar'; $Smail1='mylar@itfiling.in'; } $sql="call SP_InsertEmpDetails('".$_REQUEST['txtname']."','".$_REQUEST['txtfname']."','".$_REQUEST['txtpan']."',".$_REQUEST['txtmb'].", '".$_REQUEST['txtemail']."','".$_REQUEST['txtdob']."','".$_REQUEST['rdgender']."','".$_REQUEST['txtaccno']."','".$_REQUEST['txtmicr']."','".$_REQUEST['txtaddr1']."','".$_REQUEST['txtaddr2']."', '".$_REQUEST['txtaddr3']."','".$_REQUEST['txtaddr4']."','".$_REQUEST['txtstate']."',".$_REQUEST['txtpin'].",'".$_REQUEST['txtcmp']."','".$_REQUEST['txttan']."','".$frm."',".$_REQUEST['txtpemp'].", '".trim($Pcomp,',')."','".trim($Ptan,',')."','".trim($frm1,',')."','".$fileopt."','".$txtMdIns."','".$txtChCnt."', '".trim($txtMdIns,',')."','".trim($filesup4,',')."','".trim($filfrmoth,',')."','".trim($fiefrmincom,',')."','".trim($filoatt,',')."','".$frmPas."','".trim($frmPas1,',')."','".$fileoptPas."','".$filesupPas1."','".$filesupPas2."', '".trim($filesupPas3,',')."','".trim($filesupPas4,',')."','".trim($filfrmothPas,',')."','".trim($fiefrmincomPas,',')."','".trim($filoattPas,',')."','".$_REQUEST['txtcmnts']."','".$Smail."',".$_REQUEST['txtIncomeEarned'].")"; $rs=mysqli_query($Connection,$sql); $qry1="SELECT MAX(IT_Emp_Id) FROM it_emp_details"; $q111=mysqli_query($Connection,$qry1); //$q1=mysqli_num_rows($q111); $_SESSION['custname']=$_REQUEST['txtname'].' '.$_REQUEST['txtname']; $_SESSION['custAddress']=$_REQUEST['txtaddr1'].' '.$_REQUEST['txtaddr2'].' '.$_REQUEST['txtaddr3']; $_SESSION['custCity']=$_REQUEST['txtaddr4']; $_SESSION['custState']=$_REQUEST['txtstate']; $_SESSION['custPinCode']=$_REQUEST['txtpin']; $_SESSION['custMobileNo']=$_REQUEST['txtmb']; $_SESSION['custEmailId']=$_REQUEST['txtemail']; while( $row=mysqli_fetch_array($q111,MYSQL_NUM)) { $cus= $row[0]; } $amt=0; $qr='select set_Rate from tbl_user_info where partnerID="'.$Smail.'"'; $q1=mysqli_query($Connection,$qr); while($row=mysqli_fetch_array($q1,MYSQL_NUM)) { $amt= $row[0]; } $totamt=0; if(!empty($_REQUEST['txtaddInv'])){$totamt+=50;} if(!empty($_REQUEST['txtChCnt'])){$totamt+=50;} if(!empty($_REQUEST['txtChCnt'])){$totamt+=50;} $totamt+=$amt+(50*($_REQUEST['txtpemp'])); $netamt=(($totamt*5.2632)/100)+$totamt; $roundnetamt = round($netamt,2,PHP_ROUND_HALF_UP); $_SESSION['amt']=$roundnetamt; $csv_filename='user_'.$_REQUEST['txtpan'].'.csv'; $cr = "\n"; $csv_cnt=''; $pemp=$_REQUEST['txtpemp']; if($pemp>0) { for($i=1;$i<=$pemp;$i++) { $csv_cnt.="Company Name" . ',' .$_REQUEST['txtpcmp'.$i].','. $cr."Company TAN" . ',' .$_REQUEST['txtptan'.$i].','. $cr."Password".','.$_REQUEST['txtfrmpswd_'.$i].','. $cr; $csv_cnt.="" . ',' .','.$cr; } } $csvdata = "Income earned during the year" . ',' .$_REQUEST['txtIncomeEarned'] .','.$cr. "Name" . ',' .$_REQUEST['txtname'] .','.$cr. "Father Name" .','.$_REQUEST['txtfname'].','.$cr. "PAN" . ',' .$_REQUEST['txtpan'].','.$cr. "Mobile Number".','.$_REQUEST['txtmb'].','.$cr. "Email Id" . ',' .$_REQUEST['txtemail'].','.$cr. "DOB".','.$_REQUEST['txtdob'].','.$cr. "Gender" . ',' .$_REQUEST['rdgender'].','.$cr. "Bank Account Number".','.$_REQUEST['txtaccno'].','.$cr. "MICR Code" . ',' .$_REQUEST['txtmicr'].','.$cr. "Flat/Door/BulidRoad/Street".','.$_REQUEST['txtaddr1'].','.$cr. "Road/Street".','.$_REQUEST['txtaddr2'].','.$cr. "Area/Locality".','.$_REQUEST['txtaddr3'].','.$cr. "Town/City/District".','.$_REQUEST['txtaddr4'].','.$cr. "State" . ',' .$_REQUEST['txtstate'].','. $cr. "Pin" . ',' .$_REQUEST['txtpin'].','. $cr. "Company Name" . ',' .$_REQUEST['txtcmp'].','. $cr. "Company TAN" . ',' .$_REQUEST['txttan'].','. $cr. "Document Password if any" . ',' .$_REQUEST['txtfrmpswd'].','. $cr. "Additional Employers if any for the relevant tax period" . ',' .$_REQUEST['txtpemp'].','.$cr. $csv_cnt. "" . ',' .','.$cr. "Optional Attachment" . ',' .$_REQUEST['fileopt'].','. $cr. "Additional Investments/Savings not declared in Form 16(Optional)" . ',' .$_REQUEST['txtaddInv'].','. $cr. "Charitable contributions not declared in Form 16(Optional)" . ',' .$_REQUEST['txtChCnt'].','. $cr. "Medical Insurance not declared in Form 16 (Optional)" . ',' .$_REQUEST['txtMdIns'].','. $cr. "Form 16A of Interest and other documents" . ',' .$_REQUEST['filfrmoth'].','. $cr. "Comment / Any other addition information for filing Income Tax returns" . ',' .$_REQUEST['txtcmnts'] ; // $csvdata ="Income earned during the year" . ',' .$_REQUEST['txtIncomeEarned'] .','.$cr. "First Name" . ',' .$_REQUEST['txtname'] .','.$cr. "Father's Name" .','.$_REQUEST['txtfname'].','.$cr."PAN" . ',' .$_REQUEST['txtpan'].','.$cr. "Mobile No".','.$_REQUEST['txtmb'].','.$cr."Email" . ',' .$_REQUEST['txtemail'].','.$cr. "DOB".','.$_REQUEST['txtdob'].','.$cr."Gender" . ',' .$_REQUEST['rdgender'].','.$cr. "Bank Account Number".','.$_REQUEST['txtaccno'].','.$cr."MICR Code" . ',' .$_REQUEST['txtmicr'].','.$cr. "Flat/Door/BulidRoad/Street".','.$_REQUEST['txtaddr1'].','.$cr. "Road/Street ".','.$_REQUEST['txtaddr2'].','.$cr. "Area/Locality ".','.$_REQUEST['txtaddr3'].','.$cr. "Town/City/District".','.$_REQUEST['txtaddr4'].','.$cr."State" . ',' .$_REQUEST['txtstate'].','. $cr."PIN Code" . ',' .$_REQUEST['txtpin'].','. $cr."Company Name" . ',' .$_REQUEST['txtcmp'].','. $cr."Company TAN" . ',' .$_REQUEST['txttan'].','. $cr."No Of Prev employees" . ',' .$_REQUEST['txtpemp'].','.$cr.$csv_cnt ; // $thisfile = 'file.csv'; file_put_contents("uploads/UserDetails".$csv_filename, $csvdata); if($zip->open($zip_name, ZIPARCHIVE::CREATE)!==TRUE){ // Opening zip file to load files $error .= "* Sorry ZIP creation failed at this time<br/>"; } else { $zip->addFile($file_folder."UserDetails".$csv_filename); // Adding files into zip } $zip->close(); $my_file = $zip_name; //$my_path = $_SERVER['DOCUMENT_ROOT']."/uploads/"; $my_path = $_SERVER['DOCUMENT_ROOT']."/"; $my_name = "MYLAR"; $my_mail = $Smail1; $my_replyto = "mylar@itfiling.in"; $my_subject = "This is a mail with attachment."; $my_message = "Hai<br> Please find the attacheddocument"; mail_attachment($my_file, $my_path,$Smail1, $my_mail, $my_name, $my_replyto, $my_subject, $my_message); function mail_attachment($filename, $path, $mailto, $from_mail, $from_name, $replyto, $subject, $message) { $file = $path.$filename; $file_size = filesize($file); $handle = fopen($file, "r"); $content = fread($handle, $file_size); fclose($handle); $content = chunk_split(base64_encode($content)); $uid = md5(uniqid(time())); $name = basename($file); $header = "From: ".$from_name." <".$from_mail.">\r\n"; $header .= "Reply-To: ".$replyto."\r\n"; $header .= "MIME-Version: 1.0\r\n"; $header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n"; $msg .= "This is a multi-part message in MIME format.\r\n"; $msg .= "--".$uid."\r\n"; $msg .= "Content-type:text/plain; charset=iso-8859-1\r\n"; $msg .= "Content-Transfer-Encoding: 7bit\r\n\r\n"; $msg .= $message."\r\n\r\n"; $msg .= "--".$uid."\r\n"; $msg .= "Content-Type: application/octet-stream; name=\"".$filename."\"\r\n"; // use different content types here $msg .= "Content-Transfer-Encoding: base64\r\n"; $msg .= "Content-Disposition: attachment; filename=\"".$filename."\"\r\n\r\n"; $msg .= $content."\r\n\r\n"; $msg .= "--".$uid."--"; mail($mailto, $subject, $msg, $header) or die("unable to send mail"); } header('location:payamt.php?sub='.$Smail.'&cus='.$cus);
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.