Print Page | Close Window

Login Code

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: ASP.NET Discussion
Forum Description: Discussion and chat on ASP.NET related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=7204
Printed Date: 29 March 2026 at 3:41pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Login Code
Posted By: IrishNewbie
Subject: Login Code
Date Posted: 12 November 2003 at 2:25pm

Hey,

You know if i want to make a login feature on my site, i need to get the user to enter a ID no and password which are in the DB.

So i set up the connection and what would my query be??

when i say something like, Select Pword From Students Where etc. where does the value of Students.Pword get stored and how can i access it for authenticating the login??




Replies:
Posted By: MorningZ
Date Posted: 12 November 2003 at 2:28pm

From this http://www.asp.net/Tutorials/quickstart.aspx - set of tutorials

Comes this section, http://www.dotnetjunkies.com/quickstart/aspplus/doc/formsauth.aspx - Security

at some point you are going to have to do some research on your own instead of just leaning on a message board to solve every problem :-/



-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: Diep-Vriezer
Date Posted: 12 November 2003 at 2:37pm

I agree with MorningZ, but I've made something like this anyway, so here it is

Alright, you'll have to create a connection, a command, and a reader, like this.

Imports System.Data.OleDb

Public Function Login(UserId As String)

Dim DbConnection As New OleDbConnection, DbCommand As New OleDbCommand, DbReader As OleDbDataReader, LoginSucces As Boolean

With DbConnection

  'The connection string
  .ConnectionString = ""
  'Open the connection
  .Open()

End With

'Initialize the database command
With DbCommand

   .CommandText = "SELECT Pword FROM tblStudent WHERE UserId = '" & UserId & "'"

End With

Try

  DbReader = DbCommand.ExecuteReader()
  While DbReader.Read

     LoginSucces = True

  End While
  DbReader.Close

Catch

  LoginSucces = False

End Try

DbConnection.Close()

End Function

BTW, you're starting to look like mZeb, which is not a compliment. Please try it yourself first, and don't private message AND post a topic.



-------------
Gone..


Posted By: IrishNewbie
Date Posted: 12 November 2003 at 2:57pm

For your information I have tried it myself and cant solve the problem of figuring out away of using the value returned when i search for the pword in the table.

And morning Z ive looked at those tutorials and they gave me some of the ideas im using.



Posted By: Diep-Vriezer
Date Posted: 12 November 2003 at 3:00pm
BTW, it isn't really safe, by just validating on one id without a password.

-------------
Gone..


Posted By: IrishNewbie
Date Posted: 12 November 2003 at 3:02pm
what do you mean??


Posted By: Diep-Vriezer
Date Posted: 12 November 2003 at 3:06pm

What I mean is, when you login, you'll have to find a combination between an user name and a password. That'll be harder then just guessing an user ID, which is probably a logic ID (so all the students have the same kind of id, but are slightly different).

That way it isn't really a 'Login', since you can just guess what kind of ID someone else has, and enter that.



-------------
Gone..


Posted By: IrishNewbie
Date Posted: 12 November 2003 at 3:12pm
its my intention to use a Username/Password algorithm not just asking the student for their ID number.


Posted By: MorningZ
Date Posted: 12 November 2003 at 3:19pm
http://www.codeproject.com/aspnet/formsroleauth.asp - an excellent, easy-to-copy-and-get-working-article

-------------
Contribute to the working anarchy we fondly call the Internet



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net