|
-
Mar 3rd, 2006, 12:34 AM
#1
Thread Starter
Member
{urgent} login and passwords
Anyone here can guild me how to do login and passwords page in before user get in navigate the web pages? Any sample codes or links can provided?
I need VB code as well. and i want to ask what is the differences between the login code in html and vb language? Thanks
-
Mar 3rd, 2006, 12:54 AM
#2
Addicted Member
Re: {urgent} login and passwords
Hi asp.net,
I have a table in my db called tusers, I use this way to authenticate them:
VB Code:
Dim UserID As String = 0
Dim IsActive As Boolean = False
Dim IsDisabled As Boolean = False
Dim m As New PtechDLL.DBFunctions
Dim LoginCon As New SqlConnection(m.DBConnectionstring)
Dim LoginSQL As String = "SELECT UserID, Active, AccDisabled FROM tUser WHERE Username='" & Me.txtUsername.Text & "' AND Password='" & Me.txtPassword.Text & "'"
Dim Login As New SqlCommand(LoginSQL, LoginCon)
LoginCon.Open()
Dim LoginRead As SqlDataReader = Login.ExecuteReader
If LoginRead.HasRows = False Then
Me.lblErrors.Text = "Invalid Username or password, please try again"
Else
While LoginRead.Read
UserID = LoginRead("UserID")
IsActive = LoginRead("Active")
IsDisabled = LoginRead("AccDisabled")
End While
Session.Add("UserID", UserID)
LoginCon.Close()
Response.redirect("~/MyDashboard.aspx")
End if
If the user exists in the database, then the datareader will have rows, then I add the userid field in a session variable called "UserID" which I use for the rest of the site for db functions.
Hope it helps
-
Mar 3rd, 2006, 09:47 AM
#3
Re: {urgent} login and passwords
The difference is, there is no login code in HTML, strictly speaking.
-
Mar 4th, 2006, 02:10 AM
#4
Thread Starter
Member
Re: {urgent} login and passwords
erm, what i mean the JavaScript in html page and the javaScript in vb page. Is there any differences?
-
Mar 4th, 2006, 06:10 PM
#5
Re: {urgent} login and passwords
Yes. The difference is, you don't use javascript in a vb page. You can use Page.RegisterStartupScript or Page.RegisterClientScriptBlock to send javascript to the html that is output though.
-
Mar 4th, 2006, 06:46 PM
#6
Re: {urgent} login and passwords
If you do it this way then couldnt the credientials be read and also open to an sql injection attack?
VB Code:
"SELECT UserID, Active, AccDisabled FROM tUser WHERE Username='" & Me.txtUsername.Text & "' AND Password='" & Me.txtPassword.Text & "'"
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Mar 4th, 2006, 07:03 PM
#7
Re: {urgent} login and passwords
Yep, yep. 4guys has a sample on parameterized queries if you're too lazy to make SPs.
http://www.4guysfromrolla.com/webtech/092601-1.shtml
-
Mar 4th, 2006, 07:18 PM
#8
Re: {urgent} login and passwords
Thanks, but wasnt that site called 2guys?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Mar 4th, 2006, 07:38 PM
#9
Re: {urgent} login and passwords
 Originally Posted by RobDog888
Thanks, but wasnt that site called 2guys?
It was until cloning became legal in their country.
-
Mar 5th, 2006, 11:18 AM
#10
Thread Starter
Member
Re: {urgent} login and passwords
Dim loginInfo As New MemberDetail
Dim sqlCommand As SqlCommand
Dim sqlDataReader As SqlDataReader
sqlCommand = New SqlCommand("spLogin", sqlConnection)
sqlCommand.CommandType = CommandType.StoredProcedure
sqlCommand.Parameters.Add("@Username", SqlDbType.VarChar, 50).Value = Username.Text
sqlCommand.Parameters.Add("@Password", SqlDbType.VarChar, 50).Value = Password.Text
sqlCommand.Parameters.Add("@login_ID", SqlDbType.Int).Direction = ParameterDirection.Output
sqlConnection.Open()
sqlCommand.ExecuteNonQuery()
Dim Login_ID As Integer = CInt(sqlCommand.Parameters("@Login_ID").Value)
sqlConnection.Close()
If Login_ID > 0 Then
loginInfo.username = Username.Text
loginInfo.load = 1
Session.Add("sessionMember", loginInfo)
Response.Redirect("reservation.aspx")
Else
Dim JSCode As String = ""
JSCode &= "<script language=""javascript"">"
JSCode &= "var smessage='please key in the correct USERNAME and PASSWORD';"
JSCode &= "confirm(smessage)"
JSCode &= "</script>"
RegisterStartupScript("myjscode", JSCode)
Username.Text = ""
End If
Here is my login page. Can anyone here kindly tell me how to add Session in every page, so that the user cannot surf the pages inside if cant log in successful.Thanks.
-
Mar 5th, 2006, 12:23 PM
#11
Thread Starter
Member
Re: {urgent} login and passwords
any sample codes can provide me arr?
-
Mar 6th, 2006, 09:48 AM
#12
Re: {urgent} login and passwords
The simplest way is, in the page load of all your pages
If Session("sessionMember") = "" Then
Response.Redirect("login.aspx")
End If
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|