[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Asp Request.Form not working

Posted on 2006-04-04
10
Medium Priority
?
993 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.





0
Comment
Question by:astralliquid
  • 6
  • 2
9 Comments
 
LVL 2

Expert Comment

by:craigajhicks
ID: 16372656
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
 
LVL 1

Author Comment

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



0
 
LVL 2

Expert Comment

by:craigajhicks
ID: 16374247
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 1

Author Comment

by:astralliquid
ID: 16374563
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
 
LVL 1

Author Comment

by:astralliquid
ID: 16381693
is my points too low?
0
 
LVL 1

Author Comment

by:astralliquid
ID: 16410340
Anyone able to assist me?

Thanks
0
 
LVL 1

Author Comment

by:astralliquid
ID: 16423929
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
 
LVL 1

Author Comment

by:astralliquid
ID: 16423949
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
 

Accepted Solution

by:
GranMod earned 0 total points
ID: 16459579
Closed, 250 points refunded.
GranMod
The Experts Exchange
Community Support Moderator of all Ages
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses
Course of the Month17 days, 16 hours left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question