php - How to write a new CSV file and send as Email attachment -
ok have next code after adding phpmailer:
<?php $name = $_post['id']; $email = $_post['username']; $password = md5($_post['password']); $usergroup = $_post['usergroup']; $lastsid = $_post['lastsid']; $fname = $_post['fname']; $lname = $_post['lname']; $lastaccess = $_post['lastaccess']; $company = $_post['company']; $phone = $_post['phone']; $addone = $_post['addone']; $addtwo = $_post['addtwo']; $city = $_post['city']; $stateprov = $_post['stateprov']; $country = $_post['country']; $postalcode = $_post['postalcode']; $rescom = $_post['rescom']; $addbook = $_post['addbook']; $subscriptions = $_post['subscriptions']; $affilid = $_post['affilid']; $affilcommpct = $_post['affilcommpct']; $affilsalestodate = $_post['affilsalestodate']; $affilcommearned = $post['affilcommearned']; $affilcommowed = $_post['$affilcommowed']; $affilcommpaid = $_post['affilcommpaid']; $whlsalepct = $_post['whlsalepct']; $show_currency = $_post['show_currency']; $loyaltypoints = $_post['loyaltypoints']; $fp = fopen("feed.csv", "w+"); $savestring = $name . "," . $email . "," . $password . "," . $usergroup . "," . $lastsid . "," . $fname . "," . $lname . "," . $lastaccess . "," . $company . "," . $phone . "," . $addone . "," . $addtwo . "," . $city . "," . $stateprov . "," . $country . "," . $postalcode . "," . $rescom . "," . $addbook . "," . $subscriptions . "," . $affilid . "," . $affilcommpct . "," . $affilsalestodate . "," . $affilcommearned . "," . $affilcommowed . "," . $affilcommpaid . "," . $whlsalepct . "," . $show_currency . "," . $loyaltypoints . "\n"; fwrite($fp, $savestring); fclose($fp); echo "<h1>thank you.</h1><p>we confirm details , send new business relationship details via email within next working day.</p><p><a href='test2.php'>back main page</a></p>"; /* email finished file */ require_once('/public_html/xx/class.phpmailer.php'); $email = new phpmailer(); $email->from = 'my@emailaddress; $email->fromname = 'test name'; $email->subject = 'form test'; $email->body = $bodytext; $email->addaddress( 'my@emailaddress' ); $file_to_attach = '/public_html/xx/'; $email->addattachment( $file_to_attach, 'formdata.csv' ); homecoming $email->send(); ?>
nothing happens! please advise? getting no error logs
i have tried write $searchstring fputcsv() no success. need workaround have 1 field checkboxes options separated comma.
please help, appreciate feedback. :)
since have posted little details - can suggest following:
instead of - write on same file:
$fp = fopen("formdata.csv", "w+");
try this:
$date_time = date('y-m-d h:i:s'); $fp = fopen("formdata" . $date_time . ".csv", "w+");
and after fclose($fp);
:
trigger email code , send generated csv file attachment.
hope helps. allow me know, if want know further.
php forms csv
No comments:
Post a Comment