Now the database has been created, we can create our registration page where new members can register online. First, let's get the basic HTML code together.
<html>
<head>
<title>My Website's Registration Page</title>
</head>
<body>
<h1>Member Registration</h1>
<p>Please fill out the following form to register as a member, and gain
access to our members area.</p>
<form action="register.asp" method="POST">
<input type="hidden" name="action" value="register">
<table border="0">
<tr>
<td><b>Username</b></td>
<td><input type="text" maxlength=20 name="username"></td>
</tr>
<tr>
<td><b>Password</b></td>
<td><input type="password" maxlength=20 name="password"></td>
</tr>
<tr>
<td><b>Password Confirm</b></td>
<td><input type="password" maxlength=20 name="password_confirm"></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" value="Complete Registration"></td>
</tr>
</table>
</form>
</body>
</html>
As you can see, this is currently just plain html, and currently look something like this:
Now it's time to add some ASP code to make our form actually do something! First, we'll check to see if the form has been submitted. We can do this by checking the value of the action field, which is actually a hidden field in the form:
'see if the form has been submitted
If Request.Form("action")="register" Then
'the form has been submitted
Now we know that the form has been submitted, we need to validate it. There are a number of things we need to check:
- A username has been entered
- A password has been entered
- The passwords are the same
- That the username has not already been taken
The last item on the list cannot be done until we connect to the database, so we leave that validation until last.
Comments