ASP

 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Tutorialized ForumsWeb Design & DevelopmentASP

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Tutorialized Forums Sponsor:
  #1  
Old May 27th, 2007, 11:32 PM
Pyroboy1080 Pyroboy1080 is offline
Contributing User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 6 Pyroboy1080 New User: is a brand new recruit and a unknown entity at this point. 
Time spent in forums: 29 m 41 sec
Reputation Power: 0
ASP Login Script

I have been working on this script for logging into my website for quite some time now, and can't seem to get it working right. If anyone can help, I'd greatly appreciate it. Alright, the code is listed below:
Code:
   <%
   username = Request.Form("username")
   password = Request.Form("password")

   Dim Conn, RS

   Set Conn = Server.CreateObject("ADODB.Connection")
   Set RS = Server.CreateObject("ADODB.Recordset") 
   DSNStatement = "DRIVER=Microsoft Access Driver (*.mdb);DBQ="
   DSNStatement = DSNStatement & Server.MapPath("Login.mdb")
   Conn.Open DSNStatement

   SQLStatement = "SELECT * FROM Login1 WHERE Username = '" & username & "' AND Password = '" & password & "' "
   RS.Open SQLStatement, Conn, 3, 3

   RS.MoveFirst

   If Not RS.EOF Then
   Do Until RS.EOF
   RS.MoveNext

   user_Name = RS.Fields("Username").Value
   pass_Word = RS.Fields( "Password" ).Value

   If ( user_Name = username ) Then
      If( "password = pass_Word" ) Then
      Session("username") = username
      response.redirect( "(you have logged in page, edited out for security purposes)" )
      Else
      response.write(  "incorrect password" )
      End if
   Else
   response.write( "incorrect username" )
   End if
   Loop 

   else 
   response.write "No matches." 
   end if

   RS.close
   Conn.close 
   %>

The connection always fails, and if i use on error resume next, it only gives "Incorrect Username."

Reply With Quote
  #2  
Old September 25th, 2012, 01:39 AM
VanessaMeacham VanessaMeacham is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Location: USA
Posts: 53 VanessaMeacham User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 h 59 m 31 sec
Reputation Power: 3
Thumbs up ASP Login Script

Hi ! I can't understand in your Coding . So I put my Coding you Find the Solution From Here. I hope it will Help You.

Imports System.Data.SqlClient
Imports System.Web.Security
Imports System.Data

Partial Class Logon
Inherits System.Web.UI.Page

Private Function ValidateUser(ByVal userName As String, ByVal passWord As String) As Boolean
Dim conn As SqlConnection
Dim cmd As SqlCommand
Dim lookupPassword As String

lookupPassword = Nothing

' Check for an invalid userName.
' userName must not be set to nothing and must be between one and 15 characters.
If ((userName Is Nothing)) Then
System.Diagnostics.Trace.WriteLine("[ValidateUser] Input validation of userName failed.")
Return False
End If
If ((userName.Length = 0) Or (userName.Length > 15)) Then
System.Diagnostics.Trace.WriteLine("[ValidateUser] Input validation of userName failed.")
Return False
End If

' Check for invalid passWord.
' passWord must not be set to nothing and must be between one and 25 characters.
If (passWord Is Nothing) Then
System.Diagnostics.Trace.WriteLine("[ValidateUser] Input validation of passWord failed.")
Return False
End If
If ((passWord.Length = 0) Or (passWord.Length > 25)) Then
System.Diagnostics.Trace.WriteLine("[ValidateUser] Input validation of passWord failed.")
Return False
End If

Try
' Consult with your SQL Server administrator for an appropriate connection
' string to use to connect to your local SQL Server.
conn = New SqlConnection(ConfigurationManager.ConnectionStrin gs("SQLConnStr").ConnectionString)
conn.Open()

' Create SqlCommand to select pwd field from the users table given a supplied userName.
cmd = New SqlCommand("SELECT Password, Username FROM Users WHERE Username=@userName AND Password=@passWord", conn)
cmd.Parameters.Add("@userName", SqlDbType.VarChar, 25)
cmd.Parameters("@userName").Value = userName
cmd.Parameters.Add("@passWord", SqlDbType.VarChar, 25)
cmd.Parameters("@passWord").Value = passWord


' Execute command and fetch pwd field into lookupPassword string.
lookupPassword = cmd.ExecuteScalar()

' Cleanup command and connection objects.
cmd.Dispose()
conn.Dispose()
Catch ex As Exception
' Add error handling here for debugging.
' This error message should not be sent back to the caller.
System.Diagnostics.Trace.WriteLine("[ValidateUser] Exception " & ex.Message)
End Try

' If no password found, return false.
If (lookupPassword Is Nothing) Then
' You could write failed login attempts here to the event log for additional security.
Return False
End If

' Compare lookupPassword and input passWord by using a case-sensitive comparison.
Return (String.Compare(lookupPassword, passWord, False) = 0)

End Function

Private Sub cmdLogin_ServerClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdLogin.ServerClick
If ValidateUser(txtUserName.Value, txtUserPass.Value) Then
Dim tkt As FormsAuthenticationTicket
Dim cookiestr As String
Dim ck As HttpCookie

tkt = New FormsAuthenticationTicket(1, txtUserName.Value, DateTime.Now(), DateTime.Now.AddMinutes(30), chkPersistCookie.Checked, "your custom data")
cookiestr = FormsAuthentication.Encrypt(tkt)
ck = New HttpCookie(FormsAuthentication.FormsCookieName(), cookiestr)
If (chkPersistCookie.Checked) Then ck.Expires = tkt.Expiration
ck.Path = FormsAuthentication.FormsCookiePath()
Response.Cookies.Add(ck)

Dim strRedirect As String
strRedirect = Request("ReturnURL")
If strRedirect <> "" Then
Response.Redirect(strRedirect, True)
Else
strRedirect = "Default.aspx"
Response.Redirect(strRedirect, True)
End If
Else
Response.Redirect("Logon.aspx", True)
End If
End Sub

End Class

Reply With Quote
  #3  
Old January 29th, 2013, 06:58 AM
java88 java88 is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 1 java88 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 44 m 9 sec
Reputation Power: 0
Try this..

Code:
<%
   username = Request.Form("username")
   password = Request.Form("password")

   Dim Conn, RS

   Set Conn = Server.CreateObject("ADODB.Connection")
   Set RS = Server.CreateObject("ADODB.Recordset") 
   DSNStatement = "DRIVER=Microsoft Access Driver (*.mdb);DBQ="
   DSNStatement = DSNStatement & Server.MapPath("Login.mdb")
   Conn.Open DSNStatement

   SQLStatement = "SELECT * FROM Login1 WHERE Username = '" & username & "' AND Password = '" & password & "' "
   RS.Open SQLStatement, Conn, 3, 3

   RS.MoveFirst

   Do Until RS.EOF
   
   user_Name = RS.Fields("Username").Value
   pass_Word = RS.Fields( "Password" ).Value

   If ( username = user_Name ) And ( "password = pass_Word" ) Then
      Session("username") = username
      response.redirect( "(you have logged in page, edited out for security purposes)" )
   Exit Sub
   Else
   RS.MoveNext
   End if
   Loop 

   response.write "No matches." 

   RS.close
   Conn.close 
   %>

Last edited by java88 : January 29th, 2013 at 07:05 AM.

Reply With Quote
  #4  
Old May 15th, 2013, 07:47 AM
annaharris annaharris is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Apr 2013
Posts: 27 annaharris User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 21 m 28 sec
Reputation Power: 0
I can't understand the logic behind the code that you have shared, kindly make it simple and logical.

Reply With Quote
Reply

Viewing: Tutorialized ForumsWeb Design & DevelopmentASP > ASP Login Script


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.

© 2003-2014 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap