PDA

View Full Version : HTTP headers are already written error


JustAsking
10-01-2002, 03:11 AM
I have the following login script, but when I execute the script I receive this error:

Response object error 'ASP 0156 : 80004005'

Header Error

/internet test folder/zcorporate/login_db.asp, line 48

The HTTP headers are already written to the client browser. Any HTTP header modifications must be made before writing page content.

'This is the login script

<%@ Language = "VBScript" %>
<%
Option Explicit

Dim cnnLogin
Dim rstLogin
Dim strUsername, strPassword
Dim strSQL

%>
<html>
<head><title>Login Page</title>
</head>
<body>
<%
If Request.Form("action") <> "validate_login" Then
%>
<form action="login_db.asp" method="post">
<input type="hidden" name="action" value="validate_login" />
<table border="0">
<tr>
<td align="right">Login:</td>
<td><input type="text" name="login" /></td>
</tr>
<tr>
<td align="right">Password:</td>
<td><input type="password" name="password" /></td>
</tr>
<tr>
<td align="right"></TD>
<td><input type="submit" VALUE="Login" /></td>
</tr>
</table>
</form>
<%
Else
strSQL = "SELECT * FROM tblLoginInfo " _
& "WHERE username='" & Replace(Request.Form("login"), "'", "''") & "' " _
& "AND password='" & Replace(Request.Form("password"), "'", "''") & "';"

Set cnnLogin = Server.CreateObject("ADODB.Connection")
cnnLogin.Open("DRIVER={Microsoft Access Driver (*.mdb)};" _
& "DBQ=" & Server.MapPath("login.mdb"))

Set rstLogin = cnnLogin.Execute(strSQL)

If Not rstLogin.EOF Then
Response.Redirect "editor.asp?plan=corporateplan.htm"
%>

<%
Else
%>
<p>
<font size="4" face="arial,helvetica"><strong>
Login Failed - Please verify username and password.
</strong></font>
</p>
<p>
<a href="login_db.asp">Try Again</a>
</p>
<%

End If

rstLogin.Close
Set rstLogin = Nothing
cnnLogin.Close
Set cnnLogin = Nothing
End If
%>
</body>
</html>

glenngv
10-01-2002, 06:43 AM
put this line at the top of the page:

response.buffer=true

JustAsking
10-02-2002, 05:14 AM
glenngv,

That did it, I'll find a resource as to why it works. Thanks for you reply.

:thumbsup:

glenngv
10-02-2002, 06:19 AM
http://www.devguru.com/Technologies/asp/quickref/response_redirect.html