passing variables

Discussion in 'HTML & Website Design' started by aspbeginner, Jul 25, 2009.

  1. #1
    hi, i'm just beginning to learn web development and i jave a question about passing variables to another page or form. this is an example of the textbox <input name="email" type="text" id="email" maxlenght="20"> that whatever email address is typed by the website visitor it will pass the variable to another form. i'm using asp, vbscript and java script. thank you
     
    Last edited: Jul 25, 2009
    aspbeginner, Jul 25, 2009 IP
  2. AssistantX

    AssistantX Peon

    Messages:
    173
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #2
    There are two very easy ways to do this from a form: the POST method or the GET method.
    First you must make sure that your form is set up properly.

    <form name="input" action="receive.asp" method="post">
    <input name="email" type="text" id="email" maxlength="20">
    <input type="submit" value="Submit">
    </form>
    Code (markup):
    In the code above, action="receive.asp" specifies the page that the information will be sent to. method="post" specifies which send method you are using. POST sends the variable in the HTTP header which is unseen by the common user while GET places the variable in the URL. (Example: forumdisplay.php?f=16 , where 'f' is the variable and '16' is what it holds.) I recommend using POST because GET can get more easily abused by bots and URL testers. name="email" specifies the name of the variable that will be sent.

    Next, you must create the page that will receive the variable which in my example is "receive.asp". On that page, you will have an area in ASP code that looks like this:

    If using POST method
    dim email
    email = Request.Form("email")
    Code (markup):
    If using GET method
    dim email
    email = Request.QueryString("email")
    Code (markup):
    In both cases, the variable I created, email, will hold your form's email data.

    For more information on working with ASP and HTML, check out W3Schools
     
    AssistantX, Jul 26, 2009 IP