Session variables vs. Request.form

Results 1 to 3 of 3

Thread: Session variables vs. Request.form

  1. #1
    william Guest

    Default Session variables vs. Request.form

    Here&#039s my scenario. We&#039re redesigning our site and trying to minimize session variables. Here&#039s what I need to do:<BR><BR>I have a form with 4 fields. If one field is invalid or empty, I want the other three to return the valid data to the user, after an error message, but not save it to the database until all 4 fields are valid. Previously, session variables held this data. Can I use request.form to do this? Also, the invalid field will have a flashing error image next to it. Is there a way other than using session variables to make this work? Thanks.

  2. #2
    Anupama Guest

    Default RE: Session variables vs. Request.form

    Page: input.asp<BR><BR>&#060;form method=post action="validate.asp"<BR> &#060;input type=text value=&#060;%=request.querystring("field1")%&#062; name=field1&#062;<BR> &#060;input type=text value=&#060;%=request.querystring("field2")%&#062; name=field2&#062;<BR> &#060;input type=text value=&#060;%=request.querystring("field3")%&#062; name=field3&#062;<BR> &#060;input type=text value=&#060;%=request.querystring("field4")%&#062; name=field4&#062;<BR> &#060;input type=submit value="Submit" name=submit&#062;<BR>&#060;/form&#062;<BR><BR>Page:validate.asp<BR><BR>&#060;% <BR>tempfield1 = request.form("field1")<BR>tempfield2 = request.form("field2")<BR>tempfield3 = request.form("field3")<BR>tempfield4 = request.form("field4")<BR>if request.form("field1") = "" then<BR> Response.Redirect "input.asp?field1=" & tempfield1 & "&field2=" & tempfield2 & "&field3=" & tempfield3 & "&field4=" & tempfield4<BR><BR>after this u can write your saving code<BR>Hope it helps.If u face any problem, write at

  3. #3
    Matt Thesing Guest

    Default RE: Session variables vs. Request.form

    Another option is to put "yourself" as the Action= page.<BR><BR>For example:<BR><BR>Page: INPUT.ASP<BR>&#060;form method=POST action="input.asp"&#062;<BR><BR>At the top of INPUT.ASP you can include any processing that was in VALIDATE.ASP. If all the fields are ok, then you do the save and redirect to a success page telling the user that the update was successful.<BR><BR>Otherwise, you continue and use the Request.Form() variables that you POSTed to yourself. The first time through, these will be empty, so you can check that and not display any error indicators.<BR><BR>I have done this and it works pretty well. And using #include to include VALIDATE.ASP breaks the code up well enough (basically the same thing as having two separate files do the work, now their just combined into one - except now they both have access to your Form variables without having to embed them into your URL).<BR><BR>Of course, you can always use JavaScript to do client-side validate also. Plenty of examples for that.<BR><BR> Matt<BR>--<BR>Hometown Technologies, Inc.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts