Friday, July 26, 2024

Active Server Pages

Introduction

If you have been reading the recent newsletters on Perl then you might be interested in an alternative:

Active Server Pages (ASP). ASPs are processed before being sent from the server to the surfer, Active Server Pages controlling the information sent to the user. Although Perl isn’t going away anytime soon ASP is on the up with more and more sites using it.

Well that’s the introduction, ASP is just another way of doing the things that you can do with Perl, although a more efficient and possibly easier one!

ASP Rules OK

All programming languages have rules and ASPs are no exception.

<%

This signifies the start of the script, so we have started an ASP, now what?

Well ASPs generally work in reaction to something the user has done/inputted, so we’ll go back a step and start with a form. The user will then kindly input the information asked for and we’ll process it and send it back to them using ASP, no not very useful but it’s a start and it can be kinda fun.

This tutorial from now on assumes that you have a basic knowledge of HTML and form fields. If you don’t, head on over to HtmlGoodies.com and read through some of the tutorials offered there.

The Form
This is a simple html page with a form on it to gather information from the user, we want to know their name, favourite colour and favourite animal. Hey, whatever you’re into!

<html>
<head>
<title>Tell me about yourself</title>
</head>
<body>

<form name=”Gathering_info” method=”post” action=”story.asp”>

<p>

Your First Name: <input type=”text” name=”yName” maxlength=”20″><br>
Your Favourite Colour: <input type=”text” name=”yColour”
maxlength=”20″><br>
Your Favourite Animal: <input type=”text” name=”yAnimal”
maxlength=”20″><br>

<input type=”submit” name=”Submit” value=”Submit”>
<input type=reset name=reset value=”Reset”>

</p>

</form>

So as you can see all the fields are text boxes [<br>

<input type=”submit” name=”Submit” value=”Submit”>
</p>
</form>
</body>
</html>

And here’s the ASP, this should be saved as story.asp in the same folder as the form above.

<%
First=Request(“yName”)
Colour=Request(“yColour”)
Animal=Request(“yAnimal”)
%>
<html>
<head>
<title><%=First%>’s first story</title>
</head>
<body>
One day <%=First%> was walking down the street and a <%=Colour%> <%=Animal%> shouted out from the forest “Hey<%=First%> where are you going?”<br><%=First%> thought this was quite weird, a <%=Colour%> <%=Animal%> was talking, not only was this strange but the pink elephant down the road had told<%=First%> that it was going to happen!
<p align=”center”>
<b>THE END</b></p>
</body>
</html>

No Description

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles

Visa extension for domestic helper | 健樂護理有限公司 kl home care ltd.