Creating a Members Area in ASP

Registration Form

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.

You might also like...

Comments

About the author

James Crowley

James Crowley United Kingdom

James first started this website when learning Visual Basic back in 1999 whilst studying his GCSEs. The site grew steadily over the years while being run as a hobby - to a regular monthly audien...

Interested in writing for us? Find out more.

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Better train people and risk they leave – than do nothing and risk they stay.” - Anonymous