使用PHP和MySQL的用户推荐系统

时间:2023-01-24 18:26:27

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

我的当前注册用户表类似于

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

用户(表)- id(用户id) -电子邮件(用户电子邮件)-密码(用户密码散列)- reg_date(日期用户注册)

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.

我有一些其他的领域,但与我想做的没有关系,为了尽可能地简单,我把它们排除在外。

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:

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

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.

推荐人的推荐(表)- uid(id,这将是一个注册用户从用户表)——ref_count(总上线的用户表有提到人)——行动(也许不是仪式名称)(如果被提交完成注册的人)——我猜一些id或一些人提到,不确定,其他我可能需要什么。

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

显然在注册页面上我将有一个引用文本框,用户可以输入个人用户名被称为,检查他们提到的已经注册的会员,我想在推荐的邮件链接添加用户推荐和做一个简单的检查在注册页面注册之类的? ref = username_here

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

如果ref isset通过将用户名自动添加到文本框中。

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.

正如你所看到的,我正在努力处理推荐表背后的逻辑,如果有人能解释我还需要什么,我会很高兴。以及我在php中需要做的事情背后的逻辑,以便将它们整合在一起(而不是代码),仅仅是关于我应该做什么的一个简单的指南。我知道我需要做一些检查等检查以确保他们没有提到他们之前(垃圾邮件的原因),电子邮件的人他们想引用别人没有提到之前(垃圾邮件的原因),电子邮件的人他们想要引用不存在作为一个已经注册会员用户表等。

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.

也许我做的比实际更困难,但出于某种原因我没有理解它背后的逻辑艾尔,如果有人能告诉我,如果我做的是完全错误的,不是最好的方法请去做。

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表的模型(草稿)来做我想做的事情,以及我在php中应该做的事情,以便将它们整合到一起。

2 个解决方案

#1


4  

Set the referral table as follows:

设置转介表如下:

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

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.

遵循“不要信任任何人”的原则,您不应该在引用中使用名称作为字段。如。我发了一封推荐信:email=>your_email, name=>abuse。它一旦你。

For counting no. of referrals:

计算。推荐:

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

#2


0  

I found one query on that as I am making the same module. If the referral link is sent to another person who was not referred by the user, then what will you suggest:

我在做同样的模块时发现了一个查询。如果推荐链接被发送到另一个没有被用户推荐的人,那么您有什么建议:

(1) Either allow that person to register and pay to the user (As that can bring more users to site.) (2) Allow that person to register , but don't pay.

(1)允许该用户注册并向用户付费(这样可以为站点带来更多的用户)(2)允许该用户注册,但不付费。

#1


4  

Set the referral table as follows:

设置转介表如下:

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

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.

遵循“不要信任任何人”的原则,您不应该在引用中使用名称作为字段。如。我发了一封推荐信:email=>your_email, name=>abuse。它一旦你。

For counting no. of referrals:

计算。推荐:

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

#2


0  

I found one query on that as I am making the same module. If the referral link is sent to another person who was not referred by the user, then what will you suggest:

我在做同样的模块时发现了一个查询。如果推荐链接被发送到另一个没有被用户推荐的人,那么您有什么建议:

(1) Either allow that person to register and pay to the user (As that can bring more users to site.) (2) Allow that person to register , but don't pay.

(1)允许该用户注册并向用户付费(这样可以为站点带来更多的用户)(2)允许该用户注册,但不付费。