It is sometimes necessary to enable visitors to your website to register with your site. This would then typically give them access, via a user name and password, to various ‘restricted’ areas of your site.
Quite often when users register, they set up their own user name, and the website generates a password for them. They can then, if they wish, change their password. This type of user registration system requires no input from you, as the webmaster. If you need to enable users to set up their own web pages on your site, or have unique access to an application on your site, this is normally the type of user registration system you would use.
Alternatively, you might want to implement a system whereby the user fills in a registration form, which then generates an email that is sent to you. You can then decide whether or not you want to allow the person to register. If you do let them register, you would then email them a user name and password that they could use to access the restricted areas of the site.
You would typically use this type of user registration system when users do not require unique access to the restricted areas of your site, for example, access to price lists or other generic information that is only available to registered users.
In this article we will look at how to create a user registration system that generates an email that is automatically sent to an email address.
File 1 – form.htm
(Note: the spaces inserted in the HTML tags are for presentation purposes only. You can remove them in your version of the file.)
This first file, form.htm, is a very simple form that prompts the visitor to enter a name and email address. On a real registration form you would almost certainly request more information than this.
When the submit button is clicked, the form data is passed to file 2, sendEmail.php.
File 2 – sendEmail.php
Thank you for your registration request.
(Note: the spaces inserted in the PHP and HTML tags are for presentation purposes only. You can remove them in your version of the file.)
File 2, sendEmail.php, processes the data entered in the form, generating an email that is sent to [email protected] It also displays a message on the screen thanking the user for their registration request.