Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Help me please
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Tenchi
Starting Member

5 Posts

Posted - 23 March 2001 :  12:42:33  Show Profile  Visit Tenchi's Homepage  Send Tenchi an AOL message  Send Tenchi an ICQ Message
I am making a discussion boards for a final project in my ASP class, i am having the hardest time with two things. First it is checking to make sure that no two people are using the same User Name, I am using an Access Database to store this info in (I know it has something to do with SQL, but i am not good with that ) and the second one is the cookies, i can't seem to get the code for when the iser has the coookies to display Welcome back to the boards ______ i can't get that going.

Thanks for any help :)

ibelimb
Starting Member

10 Posts

Posted - 23 March 2001 :  13:43:17  Show Profile
Ok, Im not a ASP Programmer, BUT im a Cold Fusion Programmer, Cold fUsion also uses databses. So if i wnated to see if there are no 2 people using the usernames, In your DB where u ahve the listing of the UserNAme and Password and stuff, Add a Thing in that table Called Active. And amke ti when the user logs in Set the Active in the tables to like Yes and that way when another user logs in it will check that thing and if it says Yes, send them to a Error page and t set it to no Make a Log Out feature.

Go to Top of Page

ibelimb
Starting Member

10 Posts

Posted - 23 March 2001 :  13:43:40  Show Profile
I hope that helps and isnt to confusing

Go to Top of Page

RaiderUK
Average Member

United Kingdom
577 Posts

Posted - 23 March 2001 :  18:18:30  Show Profile  Send RaiderUK a Yahoo! Message
take the requested Username and query the username field of the database.
if EOF and BOF continue else the username is taken.

--------------------
Please let me have
more pills doctor
--------------------
Go to Top of Page

RaiderUK
Average Member

United Kingdom
577 Posts

Posted - 23 March 2001 :  18:25:26  Show Profile  Send RaiderUK a Yahoo! Message
Here is example:

Take the requested username:

Dim strUsername
StrUsername = Request.Form("usnName")

Query the database:

set rs_Check = Server.CreateObject("ADODB.Recordset")
rs_Check.ActiveConnection = CONN_STRING
rs_Check.Source = "SELECT USR_NAME FROM USER_MEMBERS WHERE M_NAME = '" + Replace(StrUsername, "'", "''") + "'"
rs_Check.CursorType = 0
rs_Check.CursorLocation = 2
rs_Check.LockType = 3
rs_Check.Open()
rs_Check_numRows = 0

Then display message if user already exists:

Dim StrMsg
If Not rs_Check.EOF Or Not rs_Check.BOF Then
StrMsg = "Username taken"
else
'Do something
end if


--------------------
Please let me have
more pills doctor
--------------------

Edited by - RaiderUK on 23 March 2001 18:28:45
Go to Top of Page

Tenchi
Starting Member

5 Posts

Posted - 03 April 2001 :  09:40:07  Show Profile  Visit Tenchi's Homepage  Send Tenchi an AOL message  Send Tenchi an ICQ Message
here is my code for it, but it isn't working :(

Sub Validate()

set cn = Server.CreateObject("ADODB.Connection")
set rs = Server.CreateObject("ADODB.Recordset")
cn.open "DSN=Discussions"

cmdsql3 = "Select * from Info"


rs.open cmdsql3,cn

'response.write cmdsql3

rs.movefirst

do while not rs.eof

if Uname = rs.fields("UserName") Then

response.write Uname
response.redirect signup.htm

rs.movenext


Else

response.write Uname

End If

Loop


End Sub

Edited by - Tenchi on 03 April 2001 09:41:53
Go to Top of Page

ljahn
Starting Member

2 Posts

Posted - 03 April 2001 :  22:55:12  Show Profile
quote:

I am making a discussion boards for a final project in my ASP class, i am having the hardest time with two things. First it is checking to make sure that no two people are using the same User Name, I am using an Access Database to store this info in (I know it has something to do with SQL, but i am not good with that ) and the second one is the cookies, i can't seem to get the code for when the iser has the coookies to display Welcome back to the boards ______ i can't get that going.

Thanks for any help :)





Go to Top of Page

Tenchi
Starting Member

5 Posts

Posted - 04 April 2001 :  10:20:14  Show Profile  Visit Tenchi's Homepage  Send Tenchi an AOL message  Send Tenchi an ICQ Message
anyone have any ideas what i am doing wrong?

Go to Top of Page

Doug G
Support Moderator

USA
6493 Posts

Posted - 04 April 2001 :  14:29:32  Show Profile
What is the problem? Hard to guess without some details on your error(s).


======
Doug G
======
Go to Top of Page

Tenchi
Starting Member

5 Posts

Posted - 05 April 2001 :  08:42:01  Show Profile  Visit Tenchi's Homepage  Send Tenchi an AOL message  Send Tenchi an ICQ Message
It hangs up, something is wrong with my logic on the if...than...else statment

Go to Top of Page

Tenchi
Starting Member

5 Posts

Posted - 05 April 2001 :  09:19:23  Show Profile  Visit Tenchi's Homepage  Send Tenchi an AOL message  Send Tenchi an ICQ Message
ok i finally got a part of that to work but now all it does is redirect even if it is correct here is my code:

<%
'for making sure there is not 2 people with the same name registered in database

Sub Validate()

set cn = Server.CreateObject("ADODB.Connection")
set rs = Server.CreateObject("ADODB.Recordset")
cn.open "DSN=Discussions"

cmdsql3 = "Select * from Info"

rs.open cmdsql3,cn

rs.movefirst

do while not rs.eof

if Uname = rs.fields("UserName") then

response.redirect "http://asp3/Final Project/Signup.htm"


Else

rs.movenext

End If

Loop


End Sub

%>


Go to Top of Page

eyekiller
Starting Member

1 Posts

Posted - 10 April 2001 :  14:49:21  Show Profile

Maybe this can help you out. Instead of validate the user checking a list of user logged on in a table 1 by 1, try to get a boolean answer to the issue if the user is looged in or not. In other words, change the query from opening the WHOLE table (SELECT * FROM Info) to a query that look for an specific CELL (SELECT * FROM Info WHERE Username=<username field>). Here is an example:

********************************************
Function Check_Admin
Dim Rs, sSQL, sLogin, sPassword, RsLOG
sLogin = Replace(Request.Form("Login"), "'", "''")
sPassword = Replace(Request.Form("Password"), "'", "''")
sSQL = "SELECT * FROM tAdmin WHERE Login='" & sLogin & "' AND Password='" & sPassword & "' "

Set Rs = Server.CreateObject("ADODB.RecordSet")

Rs.Open sSQL, sDSN, adOpenForward, adLockReadOnly, adCmdText
If Rs.EOF Then
Check_Admin = 0
Else
Session("uName")=Rs("Name")
Session("uLogin")=Rs("Login")
Session("uPassword")=Rs("Password")
Check_Admin = 1
Rs.Close
Set Rs = Nothing

End If
End Function
*********************************************

I hope this can help you....

BTW... Create Application Variables so you can make a list of aviable users online using "Dim <var>(integer number) as <type>". These way you dont need to access the database so many times.




**********************
Eyekiller 0=[=======-
**********************
Go to Top of Page

PJamieson
Starting Member

United Kingdom
11 Posts

Posted - 10 April 2001 :  16:53:01  Show Profile  Visit PJamieson's Homepage
I'd have thought that an easier way to do it was to set a primary key on the name field then check for an error from the database - it saves having to do two reads.

I can't remember the error number (book not handy) but I think its something like 4096 and I think it's called adRecIntegrityViolation. Its quicker, you can index the primary key for more speed, it's more reliable, and it isn't case sensitive like a direct match is.

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.9 seconds. Powered By: Snitz Forums 2000 Version 3.4.07