Request.Form not working - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Request.Form not working

All i want to happen is when the function login is called i can't the username and password to be displayed using response.write. At the moment it doesn't work. However if i uncomment the response.write("blah") that gets displayed. This tells me that the request.form isn't working.

[code]
<%@ Language="VBScript"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<%
Function login()
dim userName, passWord
'Response.Write("blah")
userName = Request.Form("password")
passWord = Request.Form("password")
Response.Write(userName)
Response.Write(passWord)
End Function
%>


default







SOME TABLE STUFF


Log in


Username

imageRegister


Password

 



?dostuff=1">login
<%
dostuff = Request.QueryString("dostuff")
If dostuff = 1 Then
Call login
End If
%>

[/code]

Sorry for the amount of code i posted.

Thank in advance
*Ribbleton_

Comments

  • weapon__xweapon__x Posts: 138Member
    i just noticed few things (2 iinfact):
    1.
    Function login()
    dim userName, passWord
    'Response.Write("blah")
    userName = Request.Form("password")
    passWord = Request.Form("password")
    Response.Write(userName)
    Response.Write(passWord)
    End Function
    ::: this line shoud read ( ithink ...)
    userName = Request.Form("password")====>
    userName = Request.Form("userName")

    2.


    ::: this line should read
    ===>


    where:
    "script.asp" = name of your script that will proccess the form data.

    it happens....

    baboy... baboy...

    weaps

  • aaronjones3593aaronjones3593 Posts: 122Member
    [b][red]This message was edited by aaronjones3593 at 2006-3-22 4:25:2[/red][/b][hr]
    paste over everything with the following:

    [code]
    <%@ Language="VBScript"%>

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >


    default






    <%
    IF REQUEST.FORM("POSTED") = "YES" Then
    dim userName, passWord
    userName = Request.Form("username")
    passWord = Request.Form("password")
    Response.Write(userName)
    Response.Write(passWord)
    End IF
    %>



    SOME TABLE STUFF


    Log in


    Username

    imageRegister


    Password






    [/code]

    -( Aaron )-

    "Alcohol aint the answer, but atleast you forget the question"



  • ManningManning Posts: 1,621Member
    : All i want to happen is when the function login is called i can't the username and password to be displayed using response.write. At the moment it doesn't work. However if i uncomment the response.write("blah") that gets displayed. This tells me that the request.form isn't working.
    :
    : [code]
    : <%@ Language="VBScript"%>
    :
    : <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    : <%
    : Function login()
    : dim userName, passWord
    : 'Response.Write("blah")
    : userName = Request.Form("password")
    : passWord = Request.Form("password")
    : Response.Write(userName)
    : Response.Write(passWord)
    : End Function
    : %>
    :
    :
    : default
    :
    :
    :
    :
    :
    :
    :
    : SOME TABLE STUFF
    :
    :
    : Log in
    :
    :
    : Username
    :
    : imageRegister
    :
    :
    : Password
    :
    :  
    :
    :
    :
    : ?dostuff=1">login
    : <%
    : dostuff = Request.QueryString("dostuff")
    : If dostuff = 1 Then
    : Call login
    : End If
    : %>
    :
    : [/code]

    The problem is that your "login" link sends a GET request instead of POSTing the form. You have two options:

    1) Replace the link with a submit button. ie:

    [code]?dostuff=1">login[/code]
    becomes
    [code][/code]

    2) Use javascript to make the link submit the form. ie:

    [code]?dostuff=1">login[/code]
    becomes
    [code]login[/code]

    The first option is the preferred one, since the second option would require your user have javascript enabled. (And the javascript code was off the top of my head, it might need some tweaking to work.)

    You should also change this line:

    [code]dostuff = Request.QueryString("dostuff")[/code]
    to
    [code]dostuff = Request.Form("dostuff")[/code]

    And add this line between your form tags:

    [code][/code]
Sign In or Register to comment.