Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 1.0
This is the forum to discuss the Wrox book Beginning ASP.NET 1.0 with C# by Chris Goode, John Kauffman, Christopher L. Miller, Neil Raybould, S. Srinivasa Sivakumar, Dave Sussman, Ollie Cornes, Rob Birdwell, Matt Butler, Gary Johnson, Ajoy Krishnamoorthy, Juan T. Llibre, Chris Ullman; ISBN: 9780764543708
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 1.0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 15th, 2004, 07:09 PM
Authorized User
 
Join Date: Jul 2004
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
Default Login Form ASP.NET

Hello All,

First of all I am new to .NET. I am trying to create a login (login2.aspx) form that checks an Access database table (called user) to see if the user is a valid user or not. I have seen examples, but they hard code the user/password into the page or they only check one field. I need to check both fields (username and password).

Please any help is greatly appreciated,

Thanks in Advance,
Mark.


 
Old July 17th, 2004, 12:30 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

Where do u want to check ur user & Password from?! do u use any DB?!

Always:),
Hovik Melkomian.
 
Old July 18th, 2004, 10:02 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Assuming you brought back the results to a data table:

Dim strSQL As String = select * from Users where username = '" & txtUserName.Text & "' and password = '" & txtPassword.Text & "'"
'.. load the data to a dataset or datatable, not shown here ..

if (objTable.Rows.Count > 0 ) then
  'User exists
else
  'User doesn't exist with a valid user id or password
end if

If you want to display a separate message for user id/password problems, then you need to bring the results back based on user ID, and then check the password (if (objtable.rows(0).Item("Password") = strPassword)) in your code.

Brian
 
Old July 19th, 2004, 08:56 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

    Function DBAuthenticate(ByVal strUsername As String, ByVal strPassword As String) As Integer
        Dim bResult As Boolean = False
        Dim objConn As New OleDbConnection(ConfigurationSettings.AppSettings( "myDB"))
        Dim strSQL As String
        Dim strGoodPassword As String
        Dim objCommand As New OleDbCommand

        objCommand.Connection = objConn
        strSQL = String.Format("SELECT p_w FROM myDB WHERE (email='{0}');", strUsername)
        objCommand.CommandText = strSQL
        objCommand.CommandType = CommandType.Text

        objConn.Open()
        strGoodPassword = CType(objCommand.ExecuteScalar, String)
        objConn.Close()

        If Not strGoodPassword Is Nothing Then
            If strGoodPassword = strPassword Then
                bResult = True
            Else
                lblMessage.Text = "Invalid Login!"
                lblMessage.Text &= " If you are not a member please click the above link to register."
            End If
        Else
            lblMessage.Text = "Invalid Login!"
            lblMessage.Text &= " If you are not a member please click the above link to register."
        End If

        Return bResult
    End Function

This function takes the username and password passed to it from the "Button1_Click" Sub and checks to see if they are valid. (written by PLanoie)

 
Old July 19th, 2004, 11:36 AM
Authorized User
 
Join Date: Jul 2004
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks to all that replied. I have it working. and works great.

Thanks again.
Mark






Similar Threads
Thread Thread Starter Forum Replies Last Post
asp.net login control kulkarnimonica ASP.NET 2.0 Professional 6 September 25th, 2007 05:22 PM
ASp.net 2.0 login name control kulkarnimonica ASP.NET 2.0 Professional 12 July 11th, 2007 12:42 AM
Windows Login via ASP.net rwalker VS.NET 2002/2003 9 June 20th, 2007 03:27 PM
ASP.net login page in C# in 2.0 debjanib ASP.NET 2.0 Basics 4 March 23rd, 2007 08:46 AM
how to create login page using asp.net prakashbabu ASP.NET 2.0 Basics 1 March 7th, 2007 11:52 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.