好的,我现在在添加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 will confirm your details and send your new account details via email within the next working day.</p><p><a href='test2.php'>Back to 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' );
return $email->Send();
?>
什么都没发生!请问有人可以提供建议吗?我现在没有错误日志
我还尝试将$ searchstring写为fputcsv()但没有成功。我需要解决这个问题,因为我有一个复选框字段,其中选项以逗号分隔。
请帮助,我真的很感谢您的反馈。 :)
答案 0 :(得分:0)
由于您发布了一些非常详细的信息,我可以建议:
而不是 - 总是写在同一个文件上:
$fp = fopen("formdata.csv", "w+");
试试这个:
$date_time = date('Y-m-d H:i:s');
$fp = fopen("formdata" . $date_time . ".csv", "w+");
在fclose($fp);
之后:
触发电子邮件代码并将当前生成的CSV文件作为附件发送。
希望有所帮助。如果您想进一步了解,请告诉我。