Question : How is the transition made between 2 Classic ASP pages?

I am trying to understand the flow of statements between 2 Classic ASP pages.

In observing the following pages titled default.ASP and B.ASP, could you explain the flow of the ASP pages. How is it that after default.ASP is executed initially and then B.ASP is executed up to a point and then default.ASP is executed to display the Username and Password fields and then B.ASP executes and finally devdefault.asp executes.

default.ASP
----------
<HTML>
<HEAD>
<TITLE>SOX - sign in</TITLE>
<link rel="stylesheet" href="onelook.new.css">
</HEAD>

<BODY leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" >

<table width="100%" border="0" cellspacing="0" cellpadding="0" class="bgBlueDark">
      <tr>
              <td width="30%" align=left> <img height="42" src="images/hdr_morganstanley_logo.gif" width="152"></td>
            <td width="70%" align="center"><font color=white></font></td>
            <td>&nbsp;</td>
      </tr>
      <tr>
            <td width="730" colspan="2"><img src="images/transpix.gif" width="1" height="1" vspace="1"></td>
            <td><img src="images/transpix.gif" width="1" height="1" vspace="1"></td>
      </tr>
      <tr>
            <td class="bgBlueDark" width="730" colspan="2">
            </td>
            <td class="bgBlueDark">
            </td>
      </tr>
      </table>
<%
dim msg
msg=request("msg")
      
%>
<form method="post" name="signin" action="B.asp">
<INPUT type="hidden" ID="Text3" NAME="reqid" value="<%=request("reqid")%>">
<INPUT type="hidden" ID="Text4" NAME="type" value="<%=request("type")%>">


<br><br><br><br><br>
<p align=center>
<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0" WIDTH="290" ID="Table2">
<tr>
<td colspan=3 align=center >
<%if msg=1 then%>
      <font class="txtnote">You must enter both user id and password to get into the system!<br></font><br>
<%elseif msg=2 then%>
      <font class="txtnote">The user id you've entered is invalid!<br></font><br>
<%elseif msg=3 then%>
      <font class="txtnote">The password you've entered is invalid!<br></font><br>
<%elseif msg=4 then%>
      <font class="txtnote">Your session has expired!<br></font><br>
<%end if%>
      
<font class="header">Please enter your id and password:<br></font><br></td>
</tr>

<TR>
    <TD CLASS=lineBlueDark ROWSPAN=12 WIDTH=1><IMG border=0 height=1 src="images/transpix.gif" width=1></TD>
    <TD CLASS=lineBlueDark WIDTH=290><IMG border=0 height=1 src="images/transpix.gif" width=1></TD>
    <TD ROWSPAN=82 CLASS=lineBlueDark WIDTH=1><IMG border=0 height=1 src="images/transpix.gif" width=1></TD>
</TR>
<TR>
    <TD HEIGHT="41" CLASS=bgYellowlight>
      &nbsp;
      <table border="0" width="100%" cellspacing="0" cellpadding="0" ID="Table3">
        <tr>
          <td width="40%" align="right">Username:</td>
          <td width="60%"><input type="text" name="userid" size="19" ID="Text1">
     
          </td>
        </tr>
        <tr>
          <td width="40%" align="right">Password:</td>
          <td width="60%"><input type="password" name="userpassword" size="19" ID="Password1"></td>
        </tr>
        <tr><td></td><td></td></tr>
    </table>
    </TD>
</TR>
<TR>
    <TD CLASS=lineBlueDark><IMG border=0 height=1 src="images/transpix.gif" width=1></TD>
</TR>
</TABLE>
<br>
<input type=submit value="GO">
</form>
</p>
</body>
</HTML>

******************************************************************************************************************

B.ASP
----------
<%on error resume next
dim conn
dim rst
%>
<!--#include file="dbstringFSNet.asp"-->

<HTML>
<HEAD>
<TITLE>SOX </TITLE>
<link rel="stylesheet" href="onelook.new.css">
</HEAD>

<BODY leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" >

<table width="100%" border="0" cellspacing="0" cellpadding="0" class="bgBlueDark">
      <tr>
              <td width="30%" align=left> <img height="42" src="images/hdr_y_logo.gif" width="152"></td>
            <td width="70%" align="center"><font color=white></font></td>
            <td>&nbsp;</td>
      </tr>
      <tr>
            <td width="730" colspan="2"><img src="images/transpix.gif" width="1" height="1" vspace="1"></td>
            <td><img src="images/transpix.gif" width="1" height="1" vspace="1"></td>
      </tr>
      <tr>
            <td class="bgBlueDark" width="730" colspan="2">
            </td>
            <td class="bgBlueDark">
            </td>
      </tr>
      </table>

<INPUT type="hidden" ID="Text3" NAME="reqid" value="<%=request("reqid")%>">
<INPUT type="hidden" ID="Text4" NAME="type" value="<%=request("type")%>">

<%
%>
<br><br><br><br><br>
<p align=center>
<%
dim id, usrid, pswd
usrid=Request.Form("userid")

pswd=Request.Form("userpassword")
if usrid="" or pswd="" then
      Response.Redirect "default.asp?msg=1"
      Response.End
end if
      
'function authenticate(usrid, pswd)
'Create the COMDirectory object:
'On Error Resume Next
Dim SearchObject, PersonObject, PersonObject2, PersonDN, check
Set SearchObject = server.CreateObject("MSDotNet.COMDirectory.Search")
'//InitIISEnvironment is preferred over InitVBEnvironment
'//InitIISEnvironment requires/uses AFS (\\ms\dist\) '//InitVBEnvironment uses P:
SearchObject.InitIISEnvironment

SearchObject.ConnectFWD2 "cn=finsysldap, ou=ldapids, o=y", "L0t0fWork"
'check if user id is correct
Set PersonObject = SearchObject.GetPersonByLogon(usrid)
PersonDN = SearchObject.GetPersonDN(PersonObject)
'On Error GoTo end1
'Response.Write err.number & "****"
if persondn="" then
      Response.Redirect "default.asp?msg=2"
      Response.End
else
      SearchObject.ConnectFWD2 PersonDN, pswd
      'Response.Write persondn &"$$$$$$$$$$$" & PersonObject.LogonID & "222222"
      
      Set PersonObject2 = SearchObject.GetPersonByDn(PersonDN)
      'authenticate=persondn
      'authenticate=PersonObject2.LogonID
      'Response.Write persondn & "11111111" & PersonObject2.LogonID & "222222"
      'Response.End
      id=PersonObject2.LogonID
      if id ="" then
            Response.Redirect "default.asp?msg=3"
            Response.End
      end if
      '//This will either haved raised an error, or succeeded
      Response.Write err.number & " _ " & err.description
      'End function
end if
%>
<%

authentication....

'if authenticated then:
session("id")=id

if id<>"" then
      eml=PersonObject2.emailaddress
      lname=PersonObject2.surname
      fname=PersonObject2.givenname
      session("eml")=eml
      session("lname")=lname
      session("fname")=fname

set rst= server.createobject("adodb.recordset")  
      ssql="select * from temployees where ldapid='" & id & "'"
      
      rst.Open ssql, conn, 2,2
      
      if request("type")="usr" then
            response.Redirect "usrReqDetails.asp?reqid=" & request("reqid")                               
      elseif request("type")="dev" then
            response.Redirect "devReqDetails.asp?reqid=" & request("reqid")                                     
      end if
      
      if rst.EOF then            
            response.Redirect "usrdefault.asp"
      else
            response.Redirect "devdefault.asp"
      end if
else
      Response.Redirect "default.asp"
end if
%>
</body>
</HTML>

Answer : How is the transition made between 2 Classic ASP pages?

you can use associative array notation instead of evaluate() in most cases.

suppose you have text fields text1, text2, ..., textN in your form. then on the action page you can access them inside a cfloop like this without evaluate() function:

<cfloop from="1" to="N" index="x">
#form["text" & x]#
</cfloop>

if you post your code that uses evaluate(), then we can show you how to change it to use array notation.

all the above said, evaluate() is not as bad as it used to be in cf6 and before... it's just that there are really very few cases where one needs to use it.

Azadi
Random Solutions  
 
programming4us programming4us