如何在 php oop 中创建推荐和赚钱系统
How to create refer and earn system in php oop
我正在 PHP OOP 中创建自定义电子商务网站。几乎所有(购物系统)的事情都完成了。我只想添加推荐系统。但是我不知道该怎么做。
当客户注册时,推荐 code/link 应该为该用户生成,当客户与他的朋友和他在我们网站上注册的朋友分享 link 时,推荐并使用该推荐注册的客户 code/link,双方都会得到奖励(价格)。甚至,我不明白如何制作结构。如果您知道如何创建这种系统。然后至少指导我结构以及如何创建它。
我的用户 table 在这里:
Click to see screenshot
我的插入用户函数:
public function createAccount($data){
$first_name = mysqli_real_escape_string($this->db->link, $data['first_name']);
$last_name = mysqli_real_escape_string($this->db->link, $data['last_name']);
$phone_number = mysqli_real_escape_string($this->db->link, $data['phone_number']);
$password = mysqli_real_escape_string($this->db->link, $data['password']);
if($first_name == "" || $last_name == "" || $phone_number == "" || $password == ""){
$msg = "Required fields can not be empty. Please fill the fields.";
return $msg;
} else if($this->checkPhoneNumber($phone_number) === true){
$msg = "Phone Number is already in use. Try another phone number!";
return $msg;
} else {
$query = "INSERT INTO users(first_name, last_name, phone_number, password, authority, created_on) VALUES('$first_name', '$last_name', '$phone_number', '$password', 'Customer' , NOW())";
$result = $this->db->insert($query);
if($result != false){
$func = $this->loginDuringCreatingAccount($phone_number, $password);
return $func;
}
}
}
public function checkPhoneNumber($phone_number){
$query = "SELECT `phone_number` FROM users WHERE phone_number = '$phone_number'";
$result = $this->db->select($query);
$count = @$result->num_rows;
if ($count > 0){
return true;
} else {
return false;
}
}
public function loginDuringCreatingAccount($phone_number, $password){
$query = "SELECT * FROM users WHERE phone_number = '$phone_number' AND password = '$password'";
$resultS = $this->db->select($query);
if($resultS != false){
$value = $resultS->fetch_assoc();
Session::set("userlogin", true);
Session::set("user_id", $value['user_id']);
Session::set("first_name", $value['first_name']);
Session::set("last_name", $value['last_name']);
Session::set("phone_number", $value['phone_number']);
Session::set("password", $value['password']);
header("Location: choose-username.php?step=last");
}
}
现在,我必须 update/add 此用户 table 中的一些列名称,或者对于该系统,我必须创建新的 table。如果我必须创建新的 table 然后我必须加入用户和新的 table 与否?
你能指导我创建这个系统吗?
如何在 php oop
中创建推荐和赚取系统
需要表格
- 用户(列:具有自动生成的推荐代码的用户详细信息)
- 推荐(列:ReferedBy,ReferedTo,CouponId)
- 优惠券(列:CouponId、CouponType、CouponAmount)
流量:
- 当新用户注册时,所有带有自动生成的推荐代码的详细信息都会插入用户 table。
- 当另一个新用户使用推荐码注册时,所有带有自动生成推荐码的详细信息都会插入用户table,我们将根据推荐获取用户ID,然后获取数据插入推荐 table。
优惠券 ID 将基于 Coupontype='Referral',
- 之后优惠券将发送给两个用户
我正在 PHP OOP 中创建自定义电子商务网站。几乎所有(购物系统)的事情都完成了。我只想添加推荐系统。但是我不知道该怎么做。
当客户注册时,推荐 code/link 应该为该用户生成,当客户与他的朋友和他在我们网站上注册的朋友分享 link 时,推荐并使用该推荐注册的客户 code/link,双方都会得到奖励(价格)。甚至,我不明白如何制作结构。如果您知道如何创建这种系统。然后至少指导我结构以及如何创建它。
我的用户 table 在这里:
Click to see screenshot
我的插入用户函数:
public function createAccount($data){
$first_name = mysqli_real_escape_string($this->db->link, $data['first_name']);
$last_name = mysqli_real_escape_string($this->db->link, $data['last_name']);
$phone_number = mysqli_real_escape_string($this->db->link, $data['phone_number']);
$password = mysqli_real_escape_string($this->db->link, $data['password']);
if($first_name == "" || $last_name == "" || $phone_number == "" || $password == ""){
$msg = "Required fields can not be empty. Please fill the fields.";
return $msg;
} else if($this->checkPhoneNumber($phone_number) === true){
$msg = "Phone Number is already in use. Try another phone number!";
return $msg;
} else {
$query = "INSERT INTO users(first_name, last_name, phone_number, password, authority, created_on) VALUES('$first_name', '$last_name', '$phone_number', '$password', 'Customer' , NOW())";
$result = $this->db->insert($query);
if($result != false){
$func = $this->loginDuringCreatingAccount($phone_number, $password);
return $func;
}
}
}
public function checkPhoneNumber($phone_number){
$query = "SELECT `phone_number` FROM users WHERE phone_number = '$phone_number'";
$result = $this->db->select($query);
$count = @$result->num_rows;
if ($count > 0){
return true;
} else {
return false;
}
}
public function loginDuringCreatingAccount($phone_number, $password){
$query = "SELECT * FROM users WHERE phone_number = '$phone_number' AND password = '$password'";
$resultS = $this->db->select($query);
if($resultS != false){
$value = $resultS->fetch_assoc();
Session::set("userlogin", true);
Session::set("user_id", $value['user_id']);
Session::set("first_name", $value['first_name']);
Session::set("last_name", $value['last_name']);
Session::set("phone_number", $value['phone_number']);
Session::set("password", $value['password']);
header("Location: choose-username.php?step=last");
}
}
现在,我必须 update/add 此用户 table 中的一些列名称,或者对于该系统,我必须创建新的 table。如果我必须创建新的 table 然后我必须加入用户和新的 table 与否?
你能指导我创建这个系统吗?
如何在 php oop
中创建推荐和赚取系统需要表格
- 用户(列:具有自动生成的推荐代码的用户详细信息)
- 推荐(列:ReferedBy,ReferedTo,CouponId)
- 优惠券(列:CouponId、CouponType、CouponAmount)
流量:
- 当新用户注册时,所有带有自动生成的推荐代码的详细信息都会插入用户 table。
- 当另一个新用户使用推荐码注册时,所有带有自动生成推荐码的详细信息都会插入用户table,我们将根据推荐获取用户ID,然后获取数据插入推荐 table。 优惠券 ID 将基于 Coupontype='Referral',
- 之后优惠券将发送给两个用户