使用PHP和MySQL的用户推荐系统 [英] User Referral System using PHP and MySQL

查看:278
本文介绍了使用PHP和MySQL的用户推荐系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经有一个完全承诺的会员系统,并且想要集成我自己的用户推荐系统,但是想要一些技巧和建议.

I already have a fully pledged membership system and want to integrate my own user referral system but want some tips, advice really on doing it.

我当前的注册用户表类似

My current registered users table is something like

用户(表)
-ID(用户ID)
-电子邮件(用户电子邮件)
-密码(用户密码的哈希)
-reg_date(用户注册的日期)

users (table)
- id (user id)
- email (user email)
- password (hash of users password)
- reg_date (date user registered)

我还有其他一些领域,但与我想做的事情无关,为了使事情尽可能简单,我将其遗漏了.

I have some other fields but not relevant to what I want to do and to keep things as simple as possible I left them out.

我正在考虑创建一个名为引荐的新表,例如,当我站点上的 users 表中的注册用户引用某人时(我想我会创建一个表单询问他们要推荐的人的电子邮件及其姓名,并将其添加到推荐表中),然后在该帐户中显示他们推荐的人,推荐的人数以及推荐的人是否加入了我的网站.

I am thinking of creating a new table called referrals and for example when a registered user on my site from users table refers someone (I guess I would create a form that asks for email of person they want to refer and their name and add that to referrals table) it then displays in there account who they referred and how many people they referred and if the person they referred joined up to my site.

我希望有人能在我的推荐表中解释我要跟踪推荐情况的逻辑吗?

I am hoping if someone could possibly explain the logic of what I need in my referrals table to track the referrals?

到目前为止,我的桌子看起来像这样:

My table so far looks like this:

引荐(表格)
-uid(引荐来源网址的ID,这将是用户表中的注册用户)
-ref_count(用户"表中的总推荐人已推荐人)
-动作(可能不是仪式名称)(如果被推荐的人完成了注册)
-我想为被推荐人提供一些ID或其他信息,不确定以及我可能还需要什么.

referrals (table)
- uid (id of referrer, this would be a registered user from users table)
- ref_count (total the referrer from users table has referred people)
- action (maybe not rite name) (if the person who was referred completed signup)
- I guess some id or something for the person being referred, not sure and what ever else I may need.

很明显,在注册页面上,我会有一个引荐来源网址文本框,用户可以输入他们所推荐的人的用户名,并检查他们是否已被已注册成员推荐,我想在引荐电子邮件链接中我会添加以下用户进行推介,并在注册页面上进行简单的检查,例如signup?ref = username_here

Obviously on signup page I would have a referrer text box that user can enter persons username they was referred by and checks to see if they was referred by the already registered member and i guess in a referral email link i would add user who made referral and do a simple check on sign-up page something like signup?ref=username_here

,如果通过get设置了引用,则将用户名自动添加到文本框中.

and if ref isset via get add the username automatically into text box.

如您所见,我正在努力处理推荐表背后的逻辑,如果有人可以解释我还需要什么,我会喜欢的吗?和逻辑背后的工作,我需要在php中将它们整合在一起(而不是代码),这只是我应该做什么的快速粗略指南.我知道我需要进行某些检查等检查,以确保他们以前没有推荐过他们(出于垃圾邮件的原因),并且他们想要推荐的人的电子邮件以前没有被其他人推荐(出于垃圾邮件的原因),并且他们要推荐的人的电子邮件不存在于用户表等中已注册的成员中.

As you can see I am struggling with the logic behind the referrals table and would love it if someone could explain what else I would need? and logic behind what I would need to be doing in php to bring it all together (not code) just a quick rough guide on what I should be doing. I know I would need to do certain checks etc like check to ensure they have not referred them previously (for spam reasons) and that the email of person they want to refer has not been referred by someone else previously (for spam reasons) and that the email of person they want to refer does not exists as an already registered member in users table etc.

也许我要比实际要难,但是由于某些原因我无法理解背后的逻辑,如果有人可以告诉我我在做的事情是完全错误的,而不是最好的解决方法可以.

Maybe am I making this harder than what it actually is but I am for some reason not getting the logic behind it al, if someone could tell me if what I'm doing is totally wrong and not the best way to go about it please do.

我猜你可能会说我正在请求一个参照表的模型(草稿)来完成我想要的事情,以及我应该在php中将其整合在一起的那种事情.

I guess you could say I am asking for a mockup (draft) of a referrals table to do what I want and the sort of things I should be doing in php to bring it all together.

推荐答案

设置引用表如下:

referrals:
    id (primary key)
    referrer_id (user who is referring someone else)
    referred_email (email of person being referred)
    status (referred[default], registered)
    created_on
    updated_at

遵循不信任任何人"政策,您不应将名称用作引荐中的字段.例如.我发送了一个推荐:email =>您的电子邮件,姓名=> 滥用.它会降级你.

Following the policy "do not trust anybody" you should not use name as a field in referrals. Eg. I send a referral: email=>your_email, name=>abuse. It demotes you.

用于计数引荐数:

select count(*) as referral_count from referrals where referrer_id = 'user_id'

这篇关于使用PHP和MySQL的用户推荐系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆