Home > Article > Backend Development > javascript - PHP registration invitation code
When registering
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
When registering
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>
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>
Hope it helps you