...

View Full Version : my page works using responce.write but does not when I use response.redirect ??? how



chris_angell
04-07-2003, 07:59 PM
hello I have a page I want to redirect if the user has a password etc.. When i run the code it works fine if I put response.write in replace of response.redirect.. but why does it not work when I put response.redirect, I am daffled... :confused:

have i used if statments in the wrong place ?? hmm

here is my code,,

<% @LANGUAGE = VBScript %>
<!-- #INCLUDE FILE="dbconnection.asp" -->

<%
Dim Username
Username=request.form("Username")

strSQL = "SELECT * FROM tblClients WHERE tblClients.Username = '" & Username & "'"
rst1.open strSQL, strConnect, ado_Openkeyset, ado_LockOptimistic

if not(rst1.eof) then
rst1("Hits") = rst1("Hits") + 1
rst1.update
rst1.requery
else

end if

strSQL = "SELECT * FROM tblClients WHERE tblClients.UserName = '" & Username & "' AND tblClients.Password = '" & Password & "' AND tblClients.CompanyName = '" & Companyname & "'"

if not rst1.eof then%>
<%if rst1("SalesOrTech")=false then
id=rst1("RefID")
rst1.close
set rst1=nothing
Response.write "sales/sales.asp?u=" & username & "&p=" & password & "&id=" & id
else
id=rst1("RefID")
rst1.close
set rst1=nothing
Response.write "technical/tech.asp?u=" & username & "&p=" & password & "&id=" & id

end if
else
Response.write "pages/no_login_f.htm"
end if
%>

they need to be

Response.Redirect

oh and because I was new to the asp world.. I tried to get my code to do two functions... add a hit to a field and redirect the page to an according page ????

raf
04-07-2003, 09:02 PM
maybe it's because the path is incorrect? Check the path in your browser.

Also, i always compose that value before the redirect, like this.


dim file
file="sales/sales.asp?u=" + username + "&p=" + password + "&id=" + id
response.redirect (file)

chris_angell
04-07-2003, 09:15 PM
strange... ???????

raf
04-07-2003, 10:04 PM
Come again?

Just tryed it and it does for me.

Our you sure that the "sales" and "technical" and "pages" are subfolders of the folder where this asp-page is located in?

Did you look at the url the browser tryed to open?

chris_angell
04-08-2003, 11:45 AM
um... I may be being stupid ?? thinking about it the reason it may not be working is because I don't have the sales and tech pages set up ? um but when I run this page.. it stays on this page.. the page I am trying to get the code working for...


I would have thought that it would have put the url in the browser of the page I am trying to find ??


any more help anyone


here is my page


http://www.connectonlinepreview.co.uk/temp/admin/login_f.htm

for username and password and company put chris..... but see how it stays on the login page ??

raf
04-08-2003, 01:00 PM
Looked at the code of your loginpage (the html page, not the asp)

This piece a code is wrong and is probably the cause. You probably wanted them to be reset and submit buttons, but there not.

So when you click them, nothing happens. The form isn't posted


Wrong code!!

<input border="0" src="images/submit.gif" name="Submit" type="image" width="79" height="26">
</a></td>
<td width="50%"><a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Reset','','images/reset_f2.gif',1)">
<input border="0" src="images/reset.gif" name="Reset" type="image" width="79" height="26">
</a></td>


the buttons should be something like

<input type="submit" value="Login" name="submitform">

Try this first without the javascript and see if the form gets posted.
The values will then be posted to ansa/login.asp



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum