Home > Backend Development > PHP Tutorial > javascript - PHP registration invitation code

javascript - PHP registration invitation code

WBOY
Release: 2023-03-02 11:06:02
Original
2577 people have browsed it

When registeringjavascript - PHP registration invitation code

When it is judged that the registrant of this invitation code has an invitation code, it is correct to fill in the invitation code. If there is no invitation code, there is no need to fill it in. How to write this judgment? Please let me know

Reply content:

When registeringjavascript - PHP registration invitation code

When it is judged that the registrant of this invitation code has an invitation code, it is correct to fill in the invitation code. If there is no invitation code, there is no need to fill it in. How to write this judgment? Please let me know

Since there is an invitation code, it means that your backend or database or cache or other places have normal and valid invitation codes, right? Then the user only needs to fill in the invitation code in the form. No matter what is filled in, you will get the invitation code filled in by the user and compare it with the normal and valid invitation code in your background. If they are equal, it means it is valid, and then kill the invitation code or It can be made invalid. If you don’t fill it out, don’t fill it out

I don’t quite understand what you mean. According to my understanding, the effect you want is to verify the correctness if it is filled in, and not verify if it is not filled in?
The data is sent to the backend for a non-empty verification

<code>$code = $_POST['code'];//邀请码
if(!empty($code)){
    //去数据库查询邀请码正确性
    ....
}</code>
Copy after login

PHP if...else syntax basics

The invitation code must be in your database. Then if he enters the invitation code, check whether the invitation code exists. If he does not enter the invitation code, ignore it and proceed directly to the next step

I think the general logic is like this,
The background accepts data. If the received invitation code field is empty, ignore it and use the logic without invitation code to check.
If the received invitation code is not empty, treat it as having an invitation code. Detection
So the prompts required on the previous page, such as: invitation code input box, prompt: don’t fill in if there is no invitation code

<code><?php
$code = $_POST['code'];
if(iseet($code)){
   select ... 
}
insert  ...
</code>
Copy after login

Hope it helps you

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template