If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Login Script

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-17-03, 11:21
simonfinn simonfinn is offline
Registered User
 
Join Date: Oct 2003
Posts: 22
Login Script

Hi guys

I have this login code, and i am new to ASP, i am wondering why it is not working:

Any help would be great

Thanks Si.

<%
Option Explicit

Dim ConnStr
Dim Conn
Dim rst

Sub DBConnect
ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\wwwroot\clogin\data\webjobs.mdb"
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open ConnStr
End Sub

Sub DBDisconnect
Set rst = Nothing
Conn.Close
Set Conn = Nothing
End Sub

Dim strLoginName
Dim strLoginPassword

strLoginName = Request.Form("txtLoginName")
strLoginPassword = Request.Form("txtLoginPassword")

If Len(strLoginName) > 0 Then
Call DBConnect
Set rst = Conn.Execute("SELECT Password FROM Candidate WHERE Email = '" & strLoginName & "'")
If rst.EOF <> True And rst.BOF <> True Then
If strLoginPassword = rst("Password") Then
Session("LoggedIn") = True
Response.Write("Username and password valid - redirecting......")
Response.Redirect("http://www.microsoft.com")
Else
Session("LoggedIn") = False
Response.Write("Email address or password not recognised!")
End If
Else
Response.Write("Email address or password not recognised!")
End If
Call DBDisconnect
Else
Response.Write("Email address or password not recognised!")
End If
%>
<html>

<head>
<title></title>
</head>

<body>
</body>
</html>
Reply With Quote
  #2 (permalink)  
Old 10-17-03, 13:46
Seppuku Seppuku is offline
Useless...
 
Join Date: Jul 2003
Location: SoCal
Posts: 721
Re: Login Script

What isn't working about it...

the only thing I noticed at a cursory glance was this:
Quote:
Originally posted by simonfinn
Response.Write("Username and password valid - redirecting......")
Response.Redirect("http://www.microsoft.com")
You cannot do a Response.Redirect once you've written to the browser. Changes to the document header (which a redirect is) can only be done before you start writing content to browser.
__________________
That which does not kill me postpones the inevitable.
Reply With Quote
  #3 (permalink)  
Old 10-21-03, 05:29
simonfinn simonfinn is offline
Registered User
 
Join Date: Oct 2003
Posts: 22
I think it is working now, but when i run the code outside visual interdev the browser opens up a download window to download the asp file.

Any ideas why?

Thanks Si.
Reply With Quote
  #4 (permalink)  
Old 10-21-03, 07:06
pal19 pal19 is offline
Registered User
 
Join Date: Feb 2003
Location: @ home
Posts: 163
You can leave it like you have just place this line in the middle:

Response.Write("Username and password valid - redirecting......")

Response.Flush

Response.Redirect("http://www.microsoft.com")


It will flush the line you whant and then redirect.

Paulo
Reply With Quote
  #5 (permalink)  
Old 10-21-03, 07:46
simonfinn simonfinn is offline
Registered User
 
Join Date: Oct 2003
Posts: 22
Sorry, i forgot to say i removed that line of code.

But i am unsure of why the browser is attempting to download the ASP page to disk instead of running the code. I thought it was that the ASP engine is not running, but it is.

What else could cause this?

Thanks for the help

Si
Reply With Quote
  #6 (permalink)  
Old 10-21-03, 11:04
Seppuku Seppuku is offline
Useless...
 
Join Date: Jul 2003
Location: SoCal
Posts: 721
Quote:
Originally posted by simonfinn
Sorry, i forgot to say i removed that line of code.

But i am unsure of why the browser is attempting to download the ASP page to disk instead of running the code. I thought it was that the ASP engine is not running, but it is.

What else could cause this?

Thanks for the help

Si
Make sure the website has "Execute" enabled.
__________________
That which does not kill me postpones the inevitable.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On