Asp Request.Form not working

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.





LVL 1
astralliquidAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

craigajhicksCommented:
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
0
astralliquidAuthor Commented:
My problem is not with Request("action"). Its the Request("userName") that is not working and it is not a querystring.



0
craigajhicksCommented:
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
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

astralliquidAuthor 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"-->





0
astralliquidAuthor Commented:
is my points too low?
0
astralliquidAuthor Commented:
Anyone able to assist me?

Thanks
0
astralliquidAuthor 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.
0
astralliquidAuthor 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.
0
GranModCommented:
Closed, 250 points refunded.
GranMod
The Experts Exchange
Community Support Moderator of all Ages
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.