Try viewing this in a browser, filling out its information, and clicking "Sign Up". As you can see, at the moment the page doesn't do very much. You are just returned to the same page, with the fields you filled out cleared again!
Our ASP page so far...
What we need to do now is add some code to process the inputted data. ASP provides the Request.Form property for retrieving posted form information, and uses the following syntax:
Request.Form(FieldName)
First of all, we need a way to detect if the information has been posted or not - otherwise, we won't know whether to display the form, or process it. In the original page, we included a hidden field called posted. Although the user couldn't change it, it is a useful check to see if the form has been posted. If it has, the field will have been sent along with everything else, and its value will be 1. If the Sign Up button has not been clicked (and therefore the data not posted), its value will be nothing. So, to check if the form is posted or not, we can use
If Request.Form("posted") = 1 Then 'form posted
Response.Write "<p>Thankyou for signing up</p>"
Else 'display the form %>
Your Name <input type="text" maxlength=20 name="Name"><br>
Your Email <input type="text" maxlength=100 name="Email"><br>
<input type="hidden" name="Posted" value="1">
<input type="submit" value="Sign Up">
</form>
At the moment, however, we can't really do anything with the data posted, until we know how to add it to a database. This is covered next.
Comments