Previous Article Insert Statement (Prevention of SQL Injection) |
Request.Form (How to request information from a form) |
Next Article Request.Form (Allow your visitors to play YouTube Video's in your ASP Page) |
Coding Article #: 3 - Published On: February 09, 2010 @ 12:14:55 PM - Last Updated on: July 13, 2012
This article has been Favorited 18 timesJoin today, and add this to your favorites.
Share With Friends (Updated 6-8-2010)
Supported Files
No Files for this Article.
No Files for this Article.
The Internet is full of places to go, but have you ever wondered how these pages get your information from one place to another?
Well, that is what I will teach you today.
We will get your visitors information and pass it to another page.
Now, what you do with this information is up to you. Meaning: You can take the information and send it to your email, database, cookie or a session or let it stay on the page and do nothing, which is all up to you. In this tutorial, we will take the information and place it on another page to do nothing except to show we know how to pass a variable from one page to another.
Are you ready? Let us get started then.
First, we need our form.
Next, we need to see if the Submit button has been pressed. We do that by doing a Request.Form() on the name of the input field which in this case is called: "Submit" with a value of: "Send Form"
Now we have to get the field values so that we can use them later on.
With our variables, we can use them to show the person submitting the form their values.
We do that with just the Variable names we have assigned to each form field(s) above.
Since we have already used the "IF" statement above, we can use the ELSE statement to separate the Request from the actual Form itself.
This is done by Appling the ELSE statement before the <form>
And adding the END statement, after the form.
The complete code will look like this.
That wraps up this tutorial on how to do a request on our form. Please view the code below and write one on your own to get yourself use to doing Request.Form().
Well, that is what I will teach you today.
We will get your visitors information and pass it to another page.
Now, what you do with this information is up to you. Meaning: You can take the information and send it to your email, database, cookie or a session or let it stay on the page and do nothing, which is all up to you. In this tutorial, we will take the information and place it on another page to do nothing except to show we know how to pass a variable from one page to another.
Are you ready? Let us get started then.
First, we need our form.
<form action="page.asp" method="post">
<label>First Name</label>
<div><input type="text" name="FName" /></div>
<label>Last Name</label>
<div><input type="text" name="LName" /></div>
<label>Email</label>
<div><input type="text" name="email" /></div>
<label>Submit Data</label>
<div><input type="submit" name="Submit" value="Send Form" /></div>
</form>
Next, we need to see if the Submit button has been pressed. We do that by doing a Request.Form() on the name of the input field which in this case is called: "Submit" with a value of: "Send Form"
<%if request.Form("Submit")="Send Form" then%>
Now we have to get the field values so that we can use them later on.
<%
FName = request.Form("fname")
LName = request.Form("lname")
Email = request.Form("email")
%>
With our variables, we can use them to show the person submitting the form their values.
We do that with just the Variable names we have assigned to each form field(s) above.
<%=FName%> <br />
<%=LName%> <br />
<%=Email%> <br />
Since we have already used the "IF" statement above, we can use the ELSE statement to separate the Request from the actual Form itself.
This is done by Appling the ELSE statement before the <form>
<%ELSE%>
And adding the END statement, after the form.
<%end if%>
The complete code will look like this.
<%if request.Form("Submit")="Send Form" then
FName = request.Form("fname")
LName = request.Form("lname")
Email = request.Form("email")
%>
<%=FName%> <br />
<%=LName%> <br />
<%=Email%> <br />
<%else%>
<form action="page.asp" method="post">
<label>First Name</label>
<div><input type="text" name="FName" /></div>
<label>Last Name</label>
<div><input type="text" name="LName" /></div>
<label>Email</label>
<div><input type="text" name="email" /></div>
<label>Submit Data</label>
<div><input type="submit" name="Submit" value="Send Form" /></div>
</form>
<%end if%>
That wraps up this tutorial on how to do a request on our form. Please view the code below and write one on your own to get yourself use to doing Request.Form().
Post to Facebook about: Request.Form (How to request information from a form)