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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Redirect a browser based on a conditional statement

Status
Not open for further replies.

dbrooks74

Programmer
Nov 13, 2001
105
US
I would like to see if there is a way to go to a certain page based on certain information, but anytime I ever try to do a "response.redirect ...." for example I get an error message that says I need to do it in the header, but I DON'T WANNA.

I know I'm being a big baby, but there really must be a way. Any ideas? Thanks. -db
 
I do that all the time without a problem...make sure you have this:

<%response.buffer=true%>

as the first line...that may be the problem.

hth
mb
:) &quot;Where's the Ka-Boom? There's supposed to be an Earth-shattering Ka-Boom!&quot;
Marvin the Martian
 
I think I'm still missing something. Here is my code, I will bold what is my line that is causing a problem. All other code works.

<HEAD>

<TITLE>Catch</TITLE>
<meta name=&quot;Microsoft Theme&quot; content=&quot;blends 111, default&quot;>

</HEAD>
<BODY>
<!--webbot bot=&quot;Navigation&quot; S-Orientation=&quot;horizontal&quot; S-Rendering=&quot;graphics&quot; _
S-Type=&quot;siblings&quot; B-Include-Home=&quot;TRUE&quot; B-Include-Up=&quot;TRUE&quot; --> 
<blockquote>
<blockquote>

<%
response.buffer=true
'Declare some variables
Dim sUserNameFromForm, sPasswordFromForm, con, objRS, strconnect, strHoldOldPassword

'Get the values from the form
sUserNameFromForm=request.form(&quot;USER_NAME&quot;)
sPasswordFromForm=request.form(&quot;txtPasswordBox&quot;)

'Check to see if a password was entered
If sPasswordFromForm = &quot;&quot; Then
'Since one wasn't entered then let user know, and give them the opp. to go back
response.write &quot;<FONT SIZE=+1>Please enter a password</b>&quot;
response.write &quot;<p></p><FONT SIZE=2><A HREF=ToDoListSelectPage.asp>Back</A>&quot;
Else
'A password was entered, so query database to see if they had a password before
Set con = Server.CreateObject (&quot;ADODB.Connection&quot;)
con.Open &quot;DSN=ToDoList;UID=;PWD=;&quot;
strconnect = &quot;Select USERS.USER_PASSWORD From USERS WHERE (USERS.USER_NAME) = &quot; & &quot;'&quot; _
& sUserNameFromForm & &quot;'&quot;
Set objRS = con.Execute(strconnect)

'Set the variable equal to what was in the database for the user
strHoldOldPassword=objRS(&quot;USER_PASSWORD&quot;)

'Close all objects
objRS.close
con.Close
Set objRS = Nothing
Set con = Nothing

'Check to see if it was blank
If isNull(strHoldOldPassword) Then
'User has never put in a password, so ask them to check
response.write &quot;You don't have a damn password&quot;


Else
'User has a password in there, now check to see if it is the same
If strHoldOldPassword = sPasswordFromForm Then
response.write &quot;You entered the correct password<p></p>&quot;
response.redirect &quot;
Else
'User put in the wrong password
response.write &quot;<FONT SIZE=+1>You have entered the wrong password</b>&quot;
response.write &quot;<p></p><FONT SIZE=2><A HREF=ToDoListSelectPage.asp>Back</A>&quot;
End If
End If
End If
%>

</blockquote>
</blockquote>
</BODY>
 
okay...3 things

1)<%response.buffer=true%> should be the VERY first line, even before your opening <html>

2) why the ; after your redirect?

3) there's no extension on &quot;heis_test&quot;, you may need to be more specific i.e. &quot;
hth
mb
:) &quot;Where's the Ka-Boom? There's supposed to be an Earth-shattering Ka-Boom!&quot;
Marvin the Martian
 
Ahhhhhh
It works now. Thanks so much for your help. I've been ripping my hair out all day.
 
you can just do a VBScript or Javascript:

<script langauge=&quot;javascript&quot;>
location.href = &quot;<page goes here>&quot;;
</script>
 
that's what we're all here for...next time you can save me from more hair loss! ;-) &quot;Where's the Ka-Boom? There's supposed to be an Earth-shattering Ka-Boom!&quot;
Marvin the Martian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top