Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Help needed with login SQL statement
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Help needed with login SQL statement

 Post Reply Post Reply
Author
LeoV View Drop Down
Newbie
Newbie


Joined: 18 March 2003
Status: Offline
Points: 14
Post Options Post Options   Thanks (0) Thanks(0)   Quote LeoV Quote  Post ReplyReply Direct Link To This Post Topic: Help needed with login SQL statement
    Posted: 12 June 2003 at 4:26am
I do need some help with the following. I want users to login. After this i want them to have direct access to there own details. But i do not know how to do this or what i am doing wrong.

I guess something is wrong in the SELECT..FROM...WHERE... statements! Which code i made in a blue color. But please can anybody help me..................

After login i have them directed to a check_user page to see if they exist. This is the check_user page;

<%
'Dimension variables
Dim adoCon           'Database Connection Variable
Dim strCon          'Holds the Database driver and the path and name of the database
Dim rsCheckUser      'Database Recordset Variable
Dim strAccessDB      'Holds the Access Database Name
Dim strSQL           'Database query sring
Dim strUserName      'Holds the user name

'Initalise the strUserName variable
strUserName = Request.Form("txtUserName")

'Check the database to see if user exsits and read in there password
'Initialise the strAccessDB variable with the name of the Access Database
strAccessDB = "db\Nah_Leden.mdb"

'Create a connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")
               
'Database connection info and driver
strCon = "DRIVER={Microsoft Access Driver (*.mdb)};uid=;pwd=; DBQ=" & Server.MapPath(strAccessDB)

'Set an active connection to the Connection object
adoCon.Open strCon

'Create a recordset object
Set rsCheckUser = Server.CreateObject("ADODB.Recordset")

'Initalise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT tblNah_Leden.Password FROM tblNah_Leden WHERE tblNah_Leden.UserID ='" & strUserName & "'"

'Query the database
rsCheckUser.Open strSQL, strCon

'If the recordset finds a record for the username entered then read in the password for the user
If NOT rsCheckUser.EOF Then
     
     'Read in the password for the user from the database
     If (Request.Form("txtUserPass")) = rsCheckUser("Password") Then
          
          'If the password is correct then set the session variable to True
          Session("blnIsUserGood") = True
          
          'Close Objects before redirecting
          Set adoCon = Nothing
          Set strCon = Nothing
          Set rsCheckUser = Nothing
          
          'Redirect to the authorised user page and send the users name
          Response.Redirect"Select_Eigen_gegevens.asp?name=" & strUserName

     End If
End If
          
'Close Objects
Set adoCon = Nothing
Set strCon = Nothing
Set rsCheckUser = Nothing
     
'If the script is still running then the user must not be authorised
Session("blnIsUserGood") = False
'Redirect to the unautorised user page
Response.Redirect"unauthorised_user_page.asp"
%>


So if they exist i have them directed to the Select_Eigen_gegevens.asp page. On this page i want them to have direct access to there own records.

This is a part of the Select_Eigen_gegevens.asp page;


<%@LANGUAGE="VBSCRIPT"%>

<%
' # Open the database to get Column names for the drop down list #####
set Rsemaa = Server.CreateObject("ADODB.Recordset")
Rsemaa.ActiveConnection = "DRIVER={Microsoft Access Driver (*.mdb)};uid=;pwd=;DBQ="& server.MapPath("db/Nah_Leden.mdb")
if request("id") <> "" then
     Dim SQLstring
     SQLstring = "select * from tblNah_Leden where AdresId=" & request("id")
'     response.write SQLstring
     Rsemaa.Source = SQLstring
     Rsemaa.CursorType = 0
     Rsemaa.CursorLocation = 2
     Rsemaa.LockType = 3
     Rsemaa.Open()
end if
'### If the search has been submitted create the SQL string and open another DB connection for the search

     set RsSearch = Server.CreateObject("ADODB.Recordset")
     RsSearch.ActiveConnection = "DRIVER={Microsoft Access Driver (*.mdb)};uid=;pwd=;DBQ="& server.MapPath("db/Nah_Leden.mdb")
     RsSearch.Source = SQLstring
     RsSearch.CursorType = 0
     RsSearch.CursorLocation = 2
     RsSearch.LockType = 3
     RsSearch.Open()

%>

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>


<%
'Dimension Variables
Dim strUserName     'Holds the name of the user

'Get the users name passed from the previous page
strUserName = Request.QueryString("name")
%>

            <!-- ###### Body Text ###### -->

Further HTML
<%
'#### Close it off ######
RsSearch.Close()
Set RsSearch = nothing
End if %>
</form>

Back to Top
stephen View Drop Down
Newbie
Newbie


Joined: 23 August 2002
Location: United Kingdom
Status: Offline
Points: 33
Post Options Post Options   Thanks (0) Thanks(0)   Quote stephen Quote  Post ReplyReply Direct Link To This Post Posted: 12 June 2003 at 8:30am

SQLstring = "select * from tblNah_Leden where AdresId=" & request("id")&""

is the  correct syntax  

Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post Posted: 12 June 2003 at 8:35am
You are requesting "ID" from the querystring but only pass "name" is passed.

Additionally, I would suggest checking the reject value before inserting it into a SQL statement because currently you leave yourself open to a SQL Injection attack. Search the web for more information on SQL Injection attacks.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.