How to better and more effectively implement php-user registration page

Source: Internet
Author: User
When programmers should all go to forums, they should all register forum users. the steps for registering a user on the forum are divided into several steps: Step 1 \ protocol page. only after the agreement is approved can you enter step 2 \ form for next registration, everyone who enters the forum as a programmer should go to the forum, and should register forum users. the steps for registering users on the forum are as follows:

On the first step \ agreement page, only the agreement can be approved for further registration
Step 2: Enter the registration information of the user in the form field
Step 3 \ registration result page, prompting successful registration


In actual work, if we want to develop and implement such a registration page, we should pay attention to a lot of titles:

1 \ the user skips 'Step 1 'and does not browse the protocol page. directly visit the form to enter the page through the url in step 2.
2 \ when the user completes step 3, the page is constantly refreshed, and the information entered by the user is retained once every time the user refreshes
3 \ when the user completes step 3, click back to correct a message and submit it again.


Similar forms are frequently encountered in web development. for the 3rd point, this title exists in almost all forums. 2nd points are often encountered in some message boards, but how can we avoid the title above?


Today, the boss asked me to help others upload files and promised anyone to upload the files that meet the request. the page template has been designed, which is the same as the steps for user registration. it is divided into three steps. I have done similar things before, but the anti-refresh mechanism is not well designed. if you have nothing to do today, let's take a look and see how to implement the code to avoid the above title.
-----------------------------------------------
-----------------------------------------------
The following is the personal design implementation code to avoid the above title. visit register in a browser. php, when entering the 'username 'and 'address', the two cannot be blank. if they are blank, an error message is displayed; when neither of the input boxes is blank, the submission is successful. after the submission is successful, refresh and back again to see if the results have been met.


File 1: config. inc. php

// Start session
Session_start ();

// Set not to cache locally
Header ('expires: '. date ('d, d m y h: I: S', mktime (,). 'gmt ');
Header ('last-Modified: '. gmdate ('d, d m y h: I: s'). 'gmt ');
Header ('cache-control: private, no-Cache, must-revalidate ');
Header ('pragma: no-cache ');

?>


File 2: register. php

Require_once 'config. inc. php ';

If (isset ($ _ SESSION [step2]) & isset ($ _ POST [step2]) {
// The last step of registration
$ ErrorStr = formStep3 ();
If ($ errorStr! = Null ){
Require_once('step2.html ');
} Else {
Require_once('step3.html ');
Unset ($ _ SESSION [step2], $ _ SESSION [step1]);
}

} Else if (isset ($ _ SESSION [step1]) & isset ($ _ GET [step1]) {
// Step 2 of registration
Require_once('step2.html ');

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.