导出csv文件的代码与给注册的用户邮箱发邮件的代码

1.  导出csv文件的代码 参考http://www.zxbc.cn/html/cxrs/150837493859_2.html

<?php require_once('inc/conn.php'); ?>
<?php 
$sql="select * from cge_userinfo";
$result=mysql_query($sql);
header("Content-type:application/vnd.ms-excel");  
header("Content-Disposition:filename=mail.csv");
echo "username,";
echo "Email/t/n";
while($rs=mysql_fetch_object($result)){
 echo $rs->username.",";
 echo $rs->email."/t/n";
}
?>

2. 注册的用户邮箱发邮件的代码

<?php require_once('inc/conn.php'); ?>
<?php
//写入数据库
$username=$_POST[username];
$email=$_POST[email];
$sql_insert="insert into cge_userinfo  values('','".$username."','".$email."')";
mysql_query($sql_insert);

$subject = "Welcome to CGE";  //给用户发送email主题

$from = "info@chinaglobalexchange.com";
$headers= 'Content-type: text/html; charset=utf-8'."/r/n"."From:".$from;

$attachment= "mail.html";
$fp = fopen($attachment, "r");  //打开HTML文件
$body= fread($fp, filesize($attachment));  //把整个文件读入一个变量 
$body= str_replace("***",$username,$body);  //收件人名称替换,一般用于群发

mail($email, $subject, $body, $headers);
?>
<script language="javascript">
alert("Thank you! You have sent your name and email successful.");
window.location.href="
http://www.chinaglobalexchange.net/study.html";
</script>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值