|
 |
access_asp thread: My If Else statement wont work
Message #1 by "Paul B" <lead_5@h...> on Fri, 25 Jan 2002 02:15:53
|
|
Hello
I have a database where certain users have access to certain parts of the
database.
In my database, the users table has a yes/no box (with yes meaning special
access). But, when I try and implement that with my .asp code it doesn't
work and keeps going to the same page (main.asp)
Here is the line which I have put in and keeps generating the errors:
session.fields("Choose") = 0
Does anyone have the correct code, so if the yes/no box is marked no it
goes to my certain page, else it goes to another page?
Thanks in advance
Paulo
<%response.buffer=true%>
<html><head>
<TITLE>Login</TITLE>
</head><body bgcolor="#FFFFFF">
<%
Therequester=request.form("Thisrequester")
MyName=request.form("username")
MyPassword=request.form("userpassword")
IF MyName="" OR Therequester="" OR MyPassword="" THEN
%>
Sorry, that is an invaild!<br><br>
<A href='ssignon.asp'>Try again</a>
<% response.end
END IF
set conntemp=server.createobject("adodb.connection")
cnpath="DBQ=" & server.mappath("../data/data.mdb")
conntemp.Open "DRIVER={Microsoft Access Driver (*.mdb)}; " & cnpath
sqltemp="select Username, Password, Choose from Donar where DonarCode='"
sqltemp=sqltemp & Therequester & "'"
set rstemp=conntemp.execute(SQLTemp)
IF UCase(rstemp("Username"))=UCase(MyName) THEN
IF UCase(rstemp("Password"))=UCase(MyPassword) then
session("who")=MyName
session("securitypassword")=MyPassword
session("Customer")="S"
session("Choose") = 0
response.redirect "main.asp"
Else
response.redirect "mainchoose.asp"
End IF
END IF
rstemp.close
conntemp.close
set rstemp=nothing
set conntemp=nothing
%>
Sorry <%=MyName%> that is invaild!<br><br>
Please try <A href='ssignon.asp'>Logging in</a> again
<%response.end
%>
</body></html>
Message #2 by "tan ting" <chyeting18@h...> on Fri, 25 Jan 2002 04:04:19
|
|
<html><div style='background-color:'><DIV>
<P>i had encounter this problem when i use the Yes/No box where u can check it if the value is yes...but when i use
a session variable to access it.it just can't detect....what i did was,you change the data type of the field to text box and set the
length to 3 and validation rule to "Yes" or "No". then you can access this field using Session("Choose") = "Yes" or
Session("Choose") = "No".Make sure the spelling is correct.<BR><BR></P></DIV>
<DIV></DIV>
<DIV></DIV>>From: "Paul B" <LEAD_5@H...>
<DIV></DIV>>Reply-To: "Access ASP" <ACCESS_ASP@P...>
<DIV></DIV>>To: "Access ASP" <ACCESS_ASP@P...>
<DIV></DIV>>Subject: [access_asp] My If Else statement wont work
<DIV></DIV>>Date: Fri, 25 Jan 2002 02:15:53
<DIV></DIV>>
<DIV></DIV>>Hello
<DIV></DIV>>
<DIV></DIV>>I have a database where certain users have access to certain parts of the
<DIV></DIV>>database.
<DIV></DIV>>
<DIV></DIV>>In my database, the users table has a yes/no box (with yes meaning special
<DIV></DIV>>access). But, when I try and implement that with my .asp code it doesn't
<DIV></DIV>>work and keeps going to the same page (main.asp)
<DIV></DIV>>
<DIV></DIV>>Here is the line which I have put in and keeps generating the errors:
<DIV></DIV>>
<DIV></DIV>>session.fields("Choose") = 0
<DIV></DIV>>
<DIV></DIV>>Does anyone have the correct code, so if the yes/no box is marked no it
<DIV></DIV>>goes to my certain page, else it goes to another page?
<DIV></DIV>>
<DIV></DIV>>Thanks in advance
<DIV></DIV>>Paulo
<DIV></DIV>>
<DIV></DIV>><%response.buffer=true%>
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV>><%
</DIV>>
</DIV>>
</DIV>>Therequester=request.form("Thisrequester")
</DIV>>MyName=request.form("username")
</DIV>>MyPassword=request.form("userpassword")
</DIV>> IF MyName="" OR Therequester="" OR MyPassword="" THEN
</DIV>> %>
<DIV></DIV>> Sorry, that is an invaild!<BR><BR>
<DIV></DIV>> <A href="http://lw7fd.law7.hotmail.msn.com/cgi-bin/dasp/EN/ssignon.asp">Try again</A>
<DIV></DIV>> <% response.end
</DIV>> END IF
</DIV>>
</DIV>>set conntemp=server.createobject("adodb.connection")
</DIV>>cnpath="DBQ=" & server.mappath("../data/data.mdb")
</DIV>>conntemp.Open "DRIVER={Microsoft Access Driver (*.mdb)}; " & cnpath
</DIV>>sqltemp="select Username, Password, Choose from Donar where DonarCode='"
</DIV>>sqltemp=sqltemp & Therequester & "'"
</DIV>>set rstemp=conntemp.execute(SQLTemp)
</DIV>>
</DIV>>IF UCase(rstemp("Username"))=UCase(MyName) THEN
</DIV>>
</DIV>> IF UCase(rstemp("Password"))=UCase(MyPassword) then
</DIV>> session("who")=MyName
</DIV>> session("securitypassword")=MyPassword
</DIV>> session("Customer")="S"
</DIV>> session("Choose") = 0
</DIV>> response.redirect "main.asp"
</DIV>> Else
</DIV>> response.redirect "mainchoose.asp"
</DIV>>
</DIV>> End IF
</DIV>>
</DIV>>END IF
</DIV>>
</DIV>>
</DIV>>rstemp.close
</DIV>>conntemp.close
</DIV>>set rstemp=nothing
</DIV>>set conntemp=nothing
</DIV>>
</DIV>>%>
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV>>Sorry <%=MyName%>that is invaild!<BR><BR>
<DIV></DIV>>Please try <A href="http://lw7fd.law7.hotmail.msn.com/cgi-bin/dasp/EN/ssignon.asp">Logging
in</A> again
<DIV></DIV>><%response.end
</DIV>>
</DIV>>%>
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV>>---
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV></div><br clear=all><hr>Join the world?s largest e-mail service with MSN Hotmail. <a
href='http://go.msn.com/bql/hmtag4_etl_EN.asp'>Click Here</a><br></html>
Message #3 by "Paul B" <lead_5@h...> on Tue, 29 Jan 2002 04:16:31
|
|
Thank You for your response.
Unfortunately I am still getting the same problem.
I am wondering whether session("Choose") is correct because the value in
Choose is already set within the database, the user has no control over
it, and therefore cannot choose it.
I have tried rstemp("Choose") and sqltemp("Choose") but i get an error
saying that they aren't defined. Anyone have any ideas?
Thanks
Regards
Paul
|
|
 |