Home page
 
 Home 
 ASP 
 PHP 
 SQL 
 HTML 
 JavaScript 
 Search 
 Contact 
 
Search
or browse popular tags
ASP Tutorial
Subscription

Sign up for the free email newsletter for new tips, tutorials and more. Enter your email address below, and then click the button.

Privacy Policy

RSS Twitter

How to process the data submitted from HTML form

Print

The great advantage of ASP is possibility to respond to user queries or data submitted from HTML forms. You can process information gathered by an HTML form and use ASP code to make decisions based off this information to create dynamic web pages. In this tutorial we will show how to create an HTML form and process the data.

Before you can process the information, you need to create an HTML form that will send information to your ASP page. There are two methods for sending data to an ASP form: POST and GET. These two types of sending information are defined in your HTML form element's method attribute. Also, you must specify the location of the ASP page that will process the information.

Below is a simple form that will send the data using the POST method. Information sent from a form with the POST method is invisible to others and has no limits on the amount of information to send. Copy and paste this code and save it as "form.html".

<html>
<head>
<title>Process the HTML form data with the POST method</title>
</head>
<body>
<form method="POST" action="process.asp" name="form1">
<table width="70%" border="0" cellspacing="0" cellpadding="0">
<tr>
  <td>name:</td>
  <td colspan="2"><input type="text" name="name"></td>
</tr>
<tr>
  <td>email:</td>
  <td colspan="2"><input type="text" name="email"></td>
</tr>
<tr>
  <td>comments:</td>
  <td colspan="2"><textarea name="comment" cols="40" rows="5"></textarea></td>
</tr>
<tr>
  <td>&nbsp;</td>
  <td colspan="2"><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</form>
</body>
</html>

Next, we are going to create our ASP page "process.asp" that will process the data. In our example we decided to send data with the POST method so to retrieve the information we can use the ASP 'Request.From' command. Copy and paste this code and save it in the same directory as "form.html".

<%@ Language="VBscript" %>
<html>
<head>
<title>Submitted data</title>
</head>

<body>
<%
'declare the variables that will receive the values
Dim name, email, comment
'receive the values sent from the form and assign them to variables
'note that request.form("name") will receive the value entered
'into the textfield called name
name=Request.Form("name")
email=Request.Form("email")
comment=Request.Form("comment")

'let's now print out the received values in the browser
Response.Write("Name: " & name & "<br>")
Response.Write("E-mail: " & email & "<br>")
Response.Write("Comments: " & comment & "<br>")
%>
</body>
</html>

Note: If you want to process the information sent through an HTML form with the GET method you should use the 'Request.QueryString' command . In the preceding example you should replace all instances of Form with QueryString. But remember that the data sent from a form with the GET method is visible to everyone (it will be displayed in the browser's address bar) and has limits on the amount of information to send.

'


Tags:

Add To: Add to dzone dzone | Digg this digg | Add to del.icio.us del.icio.us | Stumble it stumbleupon

  • Comments





Copyright © 2005-2014             www.WebCheatSheet.com All Rights Reserved.