Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can you explain me this code lines

Status
Not open for further replies.

Herminio

Technical User
May 10, 2002
189
PT
I have this code lines in one page(login.asp)

<%@LANGUAGE=&quot;VBSCRIPT&quot; CODEPAGE=&quot;1252&quot;%>
<!--#include file=&quot;Connections/teste.asp&quot; -->
<%
' *** Validate request to log in to this site.
MM_LoginAction = Request.ServerVariables(&quot;URL&quot;)
If Request.QueryString <>&quot;&quot; Then MM_LoginAction = MM_LoginAction + &quot;?&quot; + Request.QueryString
MM_valUsername=CStr(Request.Form(&quot;textfield&quot;))
If MM_valUsername <> &quot;&quot; Then
MM_fldUserAuthorization=&quot;&quot;
MM_redirectLoginSuccess=&quot;teste1.asp&quot;
MM_redirectLoginFailed=&quot;invalidlog.asp&quot;
MM_flag=&quot;ADODB.Recordset&quot;
set MM_rsUser = Server.CreateObject(MM_flag)
MM_rsUser.ActiveConnection = MM_teste_STRING
MM_rsUser.Source = &quot;SELECT Colect, password&quot;
If MM_fldUserAuthorization <> &quot;&quot; Then MM_rsUser.Source = MM_rsUser.Source & &quot;,&quot; & MM_fldUserAuthorization
MM_rsUser.Source = MM_rsUser.Source & &quot; FROM member WHERE Colect='&quot; & Replace(MM_valUsername,&quot;'&quot;,&quot;''&quot;) &&quot;' AND password='&quot; & Replace(Request.Form(&quot;textfield2&quot;),&quot;'&quot;,&quot;''&quot;) & &quot;'&quot;
MM_rsUser.CursorType = 0
MM_rsUser.CursorLocation = 2
MM_rsUser.LockType = 3
MM_rsUser.Open
If Not MM_rsUser.EOF Or Not MM_rsUser.BOF Then
' username and password match - this is a valid user
Session(&quot;MM_Username&quot;) = MM_valUsername
If (MM_fldUserAuthorization <> &quot;&quot;) Then
Session(&quot;MM_UserAuthorization&quot;) = CStr(MM_rsUser.Fields.Item(MM_fldUserAuthorization).Value)
Else
Session(&quot;MM_UserAuthorization&quot;) = &quot;&quot;
End If
if CStr(Request.QueryString(&quot;accessdenied&quot;)) <> &quot;&quot; And true Then
MM_redirectLoginSuccess = Request.QueryString(&quot;accessdenied&quot;)
End If
MM_rsUser.Close
Response.Redirect(MM_redirectLoginSuccess)
End If
MM_rsUser.Close
Response.Redirect(MM_redirectLoginFailed)
End If
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
</head>

<body>
<form name=&quot;form1&quot; method=&quot;POST&quot; action=&quot;<%=MM_LoginAction%>&quot;>
<label>username
<input type=&quot;text&quot; name=&quot;textfield&quot;>
</label>
<br>
<label>password
<input type=&quot;text&quot; name=&quot;textfield2&quot;>
<br>
<input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;login&quot;>
</label>
</form>
<br>
</body>
</html>

when i get to the teste1.asp page i use request.querystring(&quot;textfield&quot;) to make the SQL statement but i can't get the information passed from the first page.
Can you explain me how this works.

in this lines here i can understand that it's getting the value to assign to the URL from somewhere, but it doesn't work.

MM_LoginAction = Request.ServerVariables(&quot;URL&quot;)
If Request.QueryString <>&quot;&quot; Then MM_LoginAction = MM_LoginAction + &quot;?&quot; + Request.QueryString


 
Just want to clarify for the learning aspect of things.
method=&quot;POST&quot;
and
method=&quot;GET&quot;
are the two choices we have in how we submit form fields/values. If you use GET then you would use the Request.Querystring reuest, and for POST it would be Request.Form. This is fairly important as you have found out here, but they are from what I have seen most commeonly confused on how and where they are used. A little more, if you are posting to the same page and for some instances Request(&quot; &quot;) will also be available to use. You will surly see this at one time or another.

hope that clears things up and helps out
admin@onpntwebdesigns.com
 
i'm aware of that onpt, but i'm using Dreamweaver and if you see the code i've posted you see that the form action is a variable that DWMX creates and we've tried to use request.form also but it just doesn't work.
 
Onpnt,

I just simply always use REQUEST(&quot; &quot;) because some people press ENTER from a form (Sends using GET) and others press SUBMIT (sends using POST) even though the form method is set to POST. I find using just REQUEST(&quot; &quot;) works 100% of the time for me.

Cheers,

Gorkem.
 
Gorkem
good tip, however I have run into some issues before with restricting to that method

Herminio
Can you explain me how this works.

It sounded like that is what you were asking for. how to send values to the next page etc..

onpnt




admin@onpntwebdesigns.com
 
I think the problem lies in the fact that your using Dreamweaver.. I find using WYSIWYG products always end up messing up the final code. Why not try Visual InterDev, since it is specifically geared towards ASP development.

Just a thought..

Cheers,

Gorkem.
 
i know that it makes a messy code, but that's not the cause for the error, if it makes things that way probably they(on Macromedia)think is the best way, but it must work the same as if i was writting the code myself, don't you think?
 
I've used Session Variable to pass the value for the next page, is this correct, what are the problems with using session variable, on this situation?
 
Right at the top of the next page (upon a user hitting the submit button), do this:

Response.Write Request.Form(&quot;textfield&quot;)
Response.Write Request.Form(&quot;textfield2&quot;)

See if you're actually getting any data at all from the form. From the code, it doesn't look like there should be any problems.
To err is human, but to really foul things up requires a computer.
- Farmers' Almanac, 1978

 
If i use Session Variable it works just fine

<%@LANGUAGE=&quot;VBSCRIPT&quot; CODEPAGE=&quot;1252&quot;%>
<!--#include file=&quot;Connections/teste.asp&quot; -->
<%
Dim Recordset1__MMColParam
Recordset1__MMColParam = &quot;1&quot;
If (Session(&quot;usr&quot;) <> &quot;&quot;) Then
Recordset1__MMColParam = Session(&quot;usr&quot;)
End If
%>
<%
Dim Recordset1
Dim Recordset1_numRows

Set Recordset1 = Server.CreateObject(&quot;ADODB.Recordset&quot;)
Recordset1.ActiveConnection = MM_teste_STRING
Recordset1.Source = &quot;SELECT * FROM member WHERE Colect = '&quot; + Replace(Recordset1__MMColParam, &quot;'&quot;, &quot;''&quot;) + &quot;'&quot;
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()

Recordset1_numRows = 0
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
</head>

<body>

<% If not Recordset1.eof Then %>
</p>
<p>This is your information </p>
<p>Username: <%=(Recordset1.Fields.Item(&quot;Colect&quot;).Value)%></p>
<p>Password: <%=(Recordset1.Fields.Item(&quot;password&quot;).Value)%></p>
<% End If %>

</body>
</html>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>


Is it correct to use Session Variable in this case
 
it always seems easier to declare variables in the beginning of any script with the proper values and then use those for calculations and or conditions.
admin@onpntwebdesigns.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top