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

User Validating 1

Status
Not open for further replies.

evr72

MIS
Dec 8, 2009
265
US
I have a form that users can fill out.

When the user is done I redirect the user to an edit page where they can log out or edit any changes. All this works well. My validation code sends the users to the input form. and I would like to send the users that already have answered at least one question to the edit page I have been playing with the script below but had not gotten any luck. I would really appreciate any help or pointers
Code:
<%
	'Save the entered username and password
	Username = Request.Form("txtUsername")	
	Password = Request.Form("txtPassword")
	
	'Build connection with database
	set conn = server.CreateObject ("ADODB.Connection")		
	conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.MapPath ("qa.mdb")
	set rs = server.CreateObject ("ADODB.Recordset")		
	'Open record with entered username
	rs.Open "SELECT * FROM users where username='"& Username &"'", conn, 1 
	 Response.Cookies("ValidUser") = Validated
	'If there is no record with the entered username, close connection
	'and go back to login with QueryString
	If rs.recordcount = 0 then
		rs.close
		conn.close
		set rs=nothing
		set conn=nothing
		Response.Redirect("login.asp?login=namefailed")

	end if
	if session("Username") = rs.("username")
		response.redirect("edit")
	end if
	
	
	
	
	'If entered password is right, close connection and open mainpage
	if rs("password") = Password then
		Session("Username") = Username
		Response.Redirect("questionstry.asp")

	'If entered password is wrong, close connection 
	'and return to login with QueryString
	else
		rs.Close
		conn.Close
		set rs=nothing
		set conn=nothing
		Response.Redirect("login.asp?login=passfailed")
	end if	

%>

I added the
Code:
end if
	if session("Username") = rs.("username")
		response.redirect("edit")
	end if
line but that did not work
 
response.redirect("edit.ASP") ?




(to me it looks strange that you have the line
Response.Cookies("ValidUser") = Validated
before the actual validating process)
 
ahhhhh I got it

before the
Code:
If rs.recordcount = 0 then

I added
Code:
If rs("username") = session("Username")  then
		rs.close
		conn.close
		set rs=nothing
		set conn=nothing
		Response.Redirect("edit.asp")
	end if
And that works well.


Not I have another request I have been asked.

Is there a way that when the user gets to the last question
It can be redirected to another page. I know that in a regular form your just do a response.redirect.

but this is an edit page. When the user revises his answers he/she can edit the answers and move on to the next question. but at the end of the questions I would like to redirect them to a signature page not sure how to approach this one
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top