 |
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
|
|
|
|
|

July 15th, 2004, 07:09 PM
|
|
Authorized User
|
|
Join Date: Jul 2004
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
|

July 17th, 2004, 12:30 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
|
|
Where do u want to check ur user & Password from?! do u use any DB?!
Always:),
Hovik Melkomian.
|
|

July 18th, 2004, 10:02 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
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
|
|

July 19th, 2004, 08:56 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
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)
|
|

July 19th, 2004, 11:36 AM
|
|
Authorized User
|
|
Join Date: Jul 2004
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks to all that replied. I have it working. and works great.
Thanks again.
Mark
|
|
 |