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!

actioning twice from one form!

Status
Not open for further replies.

Govnor

Technical User
Sep 3, 2002
55
GB
Hi,

What I am trying to achieve is a login code which checks the users details in an access database and then redirects them to another page where the user will be welcomed with his/her user name.

The code I have made for the login actions the same page to check the users details! (which I would prefer to keep)

The login page is called login_db.asp and the action is equal to (=) login_db.asp.

What I would like is for the login page (login_db.asp) to action login_db.asp and also action another page called associate.asp.

The associate.asp page will request the user name from login_db.asp and welcome the user with their name. Code is <%=request.form(&quot;username&quot;) %>

So is there any possibility of being able to action more than one form. Or is there another solution to my problem rather than trying to action more than one page.

I know that it would be easier to make a login.html page, then in the login.html page action an asp page. This asp page will check the user details, then from the same asp page rename the username variable, final finish by redirecting to the last page. The last page will be the page, which welcomes the user by using the renamed username variable. (But I would like to know if there is another solution rather than the route shown in this paragraph)


Here is the Code I have currently---->
<%
If Request.Form(&quot;action&quot;) <> &quot;validate_login&quot; Then
%>
<form action=&quot;login_db.asp&quot; method=&quot;post&quot;>
<input type=&quot;hidden&quot; name=&quot;action&quot; value=&quot;validate_login&quot; />

<table border=&quot;0&quot;>
<tr>
<td align=&quot;right&quot;>Login:</td>
<td><input type=&quot;text&quot; name=&quot;username&quot; /></td>
</tr>
<tr>
<td align=&quot;right&quot;>Password:</td>
<td><input type=&quot;password&quot; name=&quot;password&quot; /></td>
</tr>
<tr>
<td align=&quot;right&quot;></TD>
<td><input type=&quot;submit&quot; VALUE=&quot;Login&quot; /></td>
</tr>
</table>
</form>
<%
Else
strSQL = &quot;SQL Statment is here!&quot;%>Then

<%response.Redirect &quot;associate.asp&quot;%>

<%
Else
%>
'Login Failed code is here!
<%
'Response.End
End If

' Clean Upcode is here!
End If
%>

Thanks
Manraj
 
Hi Manraj,

Your definately on the right track.. of course with some corrections made to the actualy code you can successfully achieve your goal....

Try this:

<%
If Request.Form(&quot;action&quot;) <> &quot;validate_login&quot; Then
%>
<form action=&quot;login_db.asp&quot; method=&quot;post&quot;>
<input type=&quot;hidden&quot; name=&quot;action&quot; value=&quot;validate_login&quot; />

<table border=&quot;0&quot;>
<tr>
<td align=&quot;right&quot;>Login:</td>
<td><input type=&quot;text&quot; name=&quot;username&quot; /></td>
</tr>
<tr>
<td align=&quot;right&quot;>Password:</td>
<td><input type=&quot;password&quot; name=&quot;password&quot; /></td>
</tr>
<tr>
<td align=&quot;right&quot;></TD>
<td><input type=&quot;submit&quot; VALUE=&quot;Login&quot; /></td>
</tr>
</table>
</form>
<%
Else

set db = server.createobject(&quot;adodb.connection&quot;)
set cmd = server.createobject(&quot;adodb.command&quot;)

db.open &quot;DSN=....;UID=...;PWD=...&quot;
cmd.activeconnection = db
cmd.commandstring = &quot;SELECT * FROM Users WHERE Username='&quot; & request(&quot;username&quot;) & &quot;'&quot;
set rs = cmd.execute

if rs.eof = false then
if request(&quot;username&quot;) = rs(&quot;username&quot;) and request(&quot;password&quot;) = rs(&quot;password&quot;) then
session(&quot;UserLoggedIn&quot;) = true
'Check SESSION(&quot;USERLOGGEDIN&quot;) on the associates page to ensure that someone didn't just enter a user a favourites link.

set cmd = nothing
set rs = nothing
set db = nothing
response.Redirect &quot;associate.asp?UID=&quot; & rs(&quot;UserID&quot;)
end if
end if
%>
'Login Failed code is here!
<%
' Clean Upcode is here!
End If
%>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top