We help IT Professionals succeed at work.

Asp Request.Form not working

astralliquid
astralliquid asked
on
Medium Priority
1,029 Views
Last Modified: 2008-03-04
I have given up Asp programming years ago. And today I faced a problem with a simple program written by myself about 2 years ago. So I don't have any idea what went wrong after losing touch for so long. (My client need me to reinstall the app on a new machine and there is no money to be made :( )

Heres the problem in short form :

<--- login.asp --->
If Request("action") = "Verify"
    userName = Request("userName")
    Response.Write "userName = " & userName
    do some sql checking
End If

<form method="post" action="login.asp?action=Verify">
    <input type=text name="userName" value="<%=Request("userName")%>">
    <submit button>
</form>
<----------------->

Ok 2 years ago it worked on XP/IIS.. the db is Access.

Today I am asked to install the same app in a new machine.

I installed XP SP2 and load the same app without any changes.

It stopped working at
userName = Request("userName")
because userName = ''

I searched the web and understand it should be written as Request.Form("userName") if action is POST. Tried it but still return empty string.

Request("action") = "Verify" works though.

Why Request("userName") is empty? why it works 2 years ago??? Did I miss out some setting on IIS??

Please help as I cannot afford to go through all the codes and change them. This shouldn't be happening because the same code works on 2 machine 2 years ago.

Is there any diff in ASP version? XP and XPSP2? Global.asa?
Request("") is defaulted to QueryString or Form? Anywhere to set this?
Will db drivers cause the problem? it is just a .mdb file and I think I haven't made any db setting (ODBC drivers) to make the app work last time.


Thanks for your help.





Comment
Watch Question

Use

<form method="post" action="login.asp">
    <input type=text name="userName" value="<%=Request("userName")%>">
    <input type=hidden name="action" value="Verify">
    <submit button>
</form>

query strings aren't excepted when using post. Try creating a hidden input field and setting its value.

Craig Hicks

Author

Commented:
My problem is not with Request("action"). Its the Request("userName") that is not working and it is not a querystring.



Sorry I am a little under the weather and I must not have read the whole question.

I would still right it the way I did as that might be part of your problem other than that use an id attribute with the name attribute.

<input type=text name="userName" id="userName" value="<%=Request("userName")%>">

Craig Hicks

Author

Commented:
I will try that tomorow and check in here again.

But just to more focus on my question :
Please try to solve my problem without ever changing any codes because they worked before. It has got to be some setting problem that I forget.

Ok heres the very same code that worked 2 years ago on IIS/XP (Worked means the user is able to login). Its doesn't work now on IIS/XP SP2 because Request("userNo") is always empty!


<%@ Language = VBScript %>
<!--#include file="db_include/db_PrepareConn.asp"-->
<%
      Option Explicit
      Response.Expires = 0
      Response.Buffer = True

      Dim bNameFailed, bPasswordFailed,objRS, Message
      bNameFailed = False
      bPasswordFailed = False

      If Request("action") = "Verify" Then
            Verify()
      End If

      Function Verify()
            Dim UserNo, Password, rs, Successful

            UserNo = Request("userNo")
            Password= Request("password")

            set rs=Server.CreateObject("ADODB.Recordset")
            strSQL =  "SELECT * FROM tUser WHERE userNo='"& userNo &"' "
            rs.Open strSQL, objconn,1

            If rs.RecordCount = 0 Then
                  bNameFailed = True
            ElseIf rs("password") = password Then
                  Session("access") = rs("accessCode")
                  Session("userId") = rs("userId")
                  Session("userName") = rs("userName")
                  Successful=True
                  Session("action")="Success"
                  Response.Redirect "CustomerList.asp?customerStatus=Active"
            Else
                  bPasswordFailed = True
            End If

            rs.close
            objconn.close
            set rs=nothing
            set objconn=nothing
      End Function

      Dim Qstr, Successful, Content, login
      Content =""
      Successful="False"

      If bNameFailed = True Then
          Content = Content & "<P>Invalid User ID</P>"
      ElseIf bPasswordFailed = True Then
            Content = Content & "<P>Invalid Password</P>"
      End If
      
%>


<form method="post" name="Login" action="login.asp?action=Verify">

<table border=0 cellpadding=3 cellspacing=0 width=100%>
<tr>
      <td valign="top" align="center" class="content-bg">
      <font color='#FF0000' size='2'><b><%=Message%></b></font>
      <input class="inputbox" type="hidden" size="12" name="LoginMessage" value="<%=Request("LoginMessage")%>">

      <center>

            <table border="1" cellspacing="1" cellpadding="0" width="300" style="border-collapse: collapse">
            <tr>
            <td>

                  <table border=0 cellspacing="0" cellpadding="0" width="300" >
                  <tr>
                        <td class="label-login" valign="bottom" align="center" colspan="2">
                              <font >Sign in &nbsp;&nbsp;µÇ½ø</font>
                        </td>
                  </tr>

                  <tr>
                        <td class="signup-label" valign="top" align="center" colspan="2" height="40" >
                              <br><font class="signup-sublabel">Enter your ID and Password to <b>Sign In</b></font>
                        </td>
                  </tr>
                  <tr>
                        <td class="signup-label" valign="top" align="center"  colspan="2">
                              <font class="message-label"><%=Content%></font>
                        </td>
                  </tr>

                  <tr>
                        <td class="signup-label" align="right" width="120" >User &nbsp;&nbsp; Óû§´úºÅ&nbsp;&nbsp;</td>
                        <td class="signup-label" align="left" width="170"  >
                              <input class="inputbox" type="text" size="12" name="userNo" value="<%=Request("userNo")%>"></td>
                  </tr>
                  <tr>
                        <td class="signup-label" align="right" >Password &nbsp;&nbsp; ÃÜÂë&nbsp;&nbsp;&nbsp;</td>
                        <td class="signup-label" align="left">
                              <input class="inputbox" type="Password" size="12" name="password" value="<%=Request("password")%>"></td>
                  </tr>
                  <tr>
                        <td class="signup-label" height="45" ></td>
                        <td class="signup-label" align="center" >
                              <input class="formbutton" type="Submit" value="Submit" name"b1">
                              <input class="formbutton" type="reset" value="Cancel" name"b2">
                        </td>
                  </tr>
                  </table>

            </td>
            </tr>
            </table>
</td>
</tr>
</table>

</form>

<!--include file="db_include/db_DisConn.asp"-->





Author

Commented:
is my points too low?

Author

Commented:
Anyone able to assist me?

Thanks

Author

Commented:
Ok it works now.

Here the solution I found out myself :

I have to allow IIS installation process to create the dir C:\Inetpub\wwwroot automatically. Having C:\Inetpub\wwwroot dir BEFORE IIS is installed will gives me the above problem.

What I did was removing dir C:\Inetpub\wwwroot and then reinstall IIS, then miraculously everything works again.

Thanks.

Author

Commented:
Btw, this happens on two new pc without IIS but already has Inetpub folders created. I have to remove the folders and reinstall IIS. I guess it's not an isolated case.
Commented:
Closed, 250 points refunded.
GranMod
The Experts Exchange
Community Support Moderator of all Ages

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.