其实这是一个系统自己带功能。。
A网友生成链接 发给好友,好友注册后,购买商品,A的帐号累计消费金额,给于返利。
新建数据库
CREATE TABLE IF NOT EXISTS `ec_tjr` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(30) NOT NULL,
`date` varchar(30) NOT NULL,
`log` text NOT NULL,
`user` varchar(30) NOT NULL,
`pass` varchar(30) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ;
--
-- 转存表中的数据 `ec_tjr`
--
INSERT INTO `ec_tjr` (`id`, `name`, `date`, `log`, `user`, `pass`) VALUES
(5, '测试', '2015-7-6 8:11:00', '', 'abc', '111');
ec_users 追加一个字段 tjr 默认值是0
在注册加入 pc和wap user.php中
/* 写入推介人 */
if (intval($_COOKIE["tjr_uid"])>0)
{
$sql = 'UPDATE ' . $ecs->table('users') . " SET `tjr`='".intval($_COOKIE["tjr_uid"])."' WHERE `user_id`='" . $_SESSION['user_id'] . "'";
$db->query($sql);
}
tjr.php 扫描二维码和推荐网址的cookie记忆地址 例如: http://www.xxx.com/tjr.php?uid=5
define('IN_ECS', true);
require(dirname(__FILE__) . '/includes/init.php');
setcookie("tjr_uid", intval($_GET['uid']), time()+3600*24);
$ua = strtolower($_SERVER['HTTP_USER_AGENT']);
$uachar = "/(nokia|sony|ericsson|mot|samsung|sgh|lg|philips|panasonic|alcatel|lenovo|cldc|midp|mobile)/i";
if(($ua == '' || preg_match($uachar, $ua))&& !strpos(strtolower($_SERVER['REQUEST_URI']),'wap'))
{
$Loaction = 'mobile/';
if (!empty($Loaction))
{
ecs_header("Location: $Loaction\n");
exit;
}
}
$Loaction = '/';
ecs_header("Location: $Loaction\n");
tj.php 推荐人 查询下线地址
<?php
define('IN_ECS', true);
require(dirname(__FILE__) . '/includes/init.php');
if($_GET['act']=='88' ){
setcookie("tjr", 0, time()+3600*24);
ecs_header("Location: tj.php");
}
if($_GET['act']=='dl' ){
$rs=$db->getRow("select * from cz_tjr where user='".$_POST['u']."'");
if ($rs['pass']==$_POST['p']){
setcookie("tjr", intval($rs['id']), time()+3600*24);
ecs_header("Location: tj.php?act=list");
exit;
}else{
echo "帐号或者密码错误.<br>";
}
}
if( intval($_COOKIE['tjr'])==0 ){ ?>
<form id="form1" name="form1" method="post" action="?act=dl"><table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="105" height="30">帐号:</td>
<td width="495">
<input name="u" type="text" id="u" />
</td>
</tr>
<tr>
<td height="30">密码:</td>
<td><input name="p" type="password" id="p" /></td>
</tr>
<tr>
<td height="30"> </td>
<td><input type="submit" name="Submit" value="提交" /></td>
</tr>
</table> </form>
<? exit;
}?>
<?
if($_GET['act']=='list' or $_GET['act']=='' ){
echo '推荐人数:'.tjs(intval($_COOKIE['tjr']))."<br>";
tjj(intval($_COOKIE['tjr']));
echo "<hr><a href='?act=88'>退出帐号</a>";
}
//------------------------------------------------------------
function tjs($id){
global $db;
$rs=$db->getRow("select count(*) as n from `ecs_users` where tjr=".$id);
return $rs['n'];
}
function tjj($id){
global $db;
$num=0;
$newlist=$db->getAll("select user_id,user_name from ecs_users where tjr=$id ");
for($i=0;$i<count($newlist);$i++){
$rs=$db->getrow("SELECT sum(goods_amount ) as m FROM `ecs_order_info`where user_id=".$newlist[$i]['user_id']." and order_status =1 and shipping_status =2 and pay_status =2");
echo '会员:'.substr($newlist[$i]['user_name'],0,10).'* -- 消费金额:'.($rs['m']+0)."元<br>";
$num+=$rs['m'];
}
echo '累计消费:'. $num;
}
?>
推荐人 注册后台 自行编写吧 就是往数据库增删改查。