classic asp request form and variables

pcapelo picture pcapelo · Sep 25, 2012 · Viewed 12k times · Source

I need some help here. I got this simple username/password script to enable a login page. It is basically a form asking a username/password and comparing with some info inside the code.

If Request.Form("FormUsername") = "username" AND Request.Form("FormPassword") = "password" Then

What I would like to do is compare user/pass info from some variable, like having a second file with the variables:

<%
'Username Variables
Dim PCUser, PCPass

PCUser = "username"
PCPass = "password"
%>

then include the file to the login page:

<!--#include file="Users.inc"-->

And then be able to read the variables on the request.form:

If Request.Form("FormUsername") = "& PCUser &" AND Request.Form("FormPassword") = "& PCPass &" Then

That's what I tried so far and didn't work :( Could anyone help me figure out why???

If I do a response.write at the end of the page it will show me the variables values:

<%
Response.Write("user= " & PCUser & "<br />")
Response.Write("pass= " & PCPass & "<br />")
%>

thanks in advance

PC

Answer

Valamas picture Valamas · Sep 25, 2012

try

If Request.Form("FormUsername") = PCUser 
      AND Request.Form("FormPassword") = PCPass Then

2nd try:

response.write "FormUsername: " & Request.Form("FormUsername")
response.write "PCUser: " & PCUser
response.write "Equals: " & (Request.Form("FormUsername") = PCUser)

Check using the above in both the main page and the include file.