
Validate logins with ASP, MS Access and Cookies error
Hi, while trying to validate username and password on login form I am
presented with the following error message
Microsoft JET Database Engine error '80040e10'
No value given for one or more required parameters.
/vdateUsr.asp, line 53
The 2 fields within the database are text fields (UID) and (PWD) these are
spelt correctly!
This is the code that I am using:
<% [at] Language=VBScript%>
<!-- METADATA TYPE="typelib"
FILE="C:\Program Files\Common
Files\System\ado\msado15.dll" -->
<!-- #include file="Connectionstring.asp" -->
<%
' /////////////////////////////////////
' login validation script
' © Matt Millross
' www.designplace.org
' free for use as long as copyright notice left intact
' For more scripts, visit www.designplace.org
' /////////////////////////////////////
' variables
dim cnStr
dim rcSet
dim frmUsername
dim frmPassword
dim sqlStr
'store form input into variables
frmUsername = Request.Form("UID")
frmPassword = Request.Form("PWD")
'create connection and recordset objects
Set cnStr = Server.CreateObject("ADODB.Connection")
Set rcSet = Server.CreateObject("ADODB.Recordset")
' defining database connection (connectionstring.asp)
cnStr.ConnectionString = path
cnStr.Provider = provider
cnStr.open
' execute sql and open as recordset
sqlStr = "Select * From tblusers where username = '" _
& Request.Form("UID") & "' and password = '" & Request.Form("PWD") & "'"
' Opens the returned values from the SQL as a recordset, ready for iteration
by ASP
<<< LINE 53 >>> set rcSet = cnStr.Execute(sqlStr)
' validate variables against database
If (not rcSet.BOF) and (not rcSet.EOF) then
response.cookies("validated_user") = frmUsername
response.write "<h1>Login successful!</h1>"
response.write "<p>Welcome " & rcSet.fields(1) & "</p>"
else
response.write "incorrect username and/or password"
end if
%>
Unfortunately I am new to all this and would welcome any feedback on this
error.
Malcolm
Re: Validate logins with ASP, MS Access and Cookies error
Give this a try ........
'// BEGIN
<% [at] Language="VBScript"%>
<%Option Explicit%>
<!-- METADATA TYPE="typelib" FILE="C:\Program Files\Common
Files\System\ado\msado15.dll" -->
<!-- #include file="Connectionstring.asp" -->
<%
' /////////////////////////////////////
' login validation script
' © Matt Millross
' www.designplace.org
' free for use as long as copyright notice left intact
' For more scripts, visit www.designplace.org
' /////////////////////////////////////
' variables
dim cnStr, rcSet, frmUsername, frmPassword, sqlStr
'store form input into variables
frmUsername = Request.Form("UID")
frmPassword = Request.Form("PWD")
'create connection and recordset objects
Set cnStr = Server.CreateObject("ADODB.Connection")
'// THIS IS NOT NEEDED!
'// Set rcSet = Server.CreateObject("ADODB.Recordset")
' defining database connection (connectionstring.asp)
cnStr.ConnectionString = path
cnStr.Provider = provider
cnStr.open
' execute sql and open as recordset
'// sqlStr = "Select * From tblusers where username = '" _
'// & Request.Form("UID") & "' and password = '" & Request.Form("PWD") &
"'"
'// You've already stored the user/pass into a local var - use them!
'// and NEVER use "Select * ..."
'//
'// http://aspfaq.com/show.asp?id 96
sqlStr = "Select username, password from tblUsers Where username = '" _
& frmUsername & "' AND password = '" & frmPassword & "'"
' Opens the returned values from the SQL as a recordset,
' ready for iteration by ASP
'// <<< LINE 53 >>> set rcSet = cnStr.Execute(sqlStr)
' validate variables against database
// If (not rcSet.BOF) and (not rcSet.EOF) then
'// Check before processing
If Len(frmUsername) < 1 Then frmUsername = "NULL"
If Len(frmPassword) < 1 Then frmPassword = "NULL"
'// Then go...
Set rcSet = cnStr.Execute(sqlStr)
If NOT rcSet.EOF Then
response.cookies("validated_user") = frmUsername
response.write "<h1>Login successful!</h1>"
'// Forget using rcSet.Fields, and just use rcSet
'// directly
response.write "<p>Welcome " & rcSet(1) & "</p>"
else
response.write "incorrect username and/or password"
end if
'// Don't forget to cleanup after yourself
cnStr.Close: Set cnStr = Nothing
Set rcSet = Nothing
%>
'// END
--
Regards
Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk
Keeping it FREE!
"malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
news:44410c1c$0$23181$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
> Hi, while trying to validate username and password on login form I am
> presented with the following error message
>
>
> Microsoft JET Database Engine error '80040e10'
>
> No value given for one or more required parameters.
>
> /vdateUsr.asp, line 53
>
> The 2 fields within the database are text fields (UID) and (PWD) these are
> spelt correctly!
>
> This is the code that I am using:
>
> <% [at] Language=VBScript%>
>
> <!-- METADATA TYPE="typelib"
> FILE="C:\Program Files\Common
> Files\System\ado\msado15.dll" -->
> <!-- #include file="Connectionstring.asp" -->
>
>
> <%
> ' /////////////////////////////////////
> ' login validation script
> ' © Matt Millross
> ' www.designplace.org
> ' free for use as long as copyright notice left intact
> ' For more scripts, visit www.designplace.org
> ' /////////////////////////////////////
>
> ' variables
> dim cnStr
> dim rcSet
> dim frmUsername
> dim frmPassword
> dim sqlStr
>
> 'store form input into variables
> frmUsername = Request.Form("UID")
> frmPassword = Request.Form("PWD")
>
> 'create connection and recordset objects
> Set cnStr = Server.CreateObject("ADODB.Connection")
> Set rcSet = Server.CreateObject("ADODB.Recordset")
>
> ' defining database connection (connectionstring.asp)
> cnStr.ConnectionString = path
> cnStr.Provider = provider
> cnStr.open
>
> ' execute sql and open as recordset
> sqlStr = "Select * From tblusers where username = '" _
> & Request.Form("UID") & "' and password = '" & Request.Form("PWD") &
"'"
>
> ' Opens the returned values from the SQL as a recordset, ready for
iteration
> by ASP
> <<< LINE 53 >>> set rcSet = cnStr.Execute(sqlStr)
> ' validate variables against database
> If (not rcSet.BOF) and (not rcSet.EOF) then
> response.cookies("validated_user") = frmUsername
> response.write "<h1>Login successful!</h1>"
> response.write "<p>Welcome " & rcSet.fields(1) & "</p>"
> else
> response.write "incorrect username and/or password"
> end if
> %>
>
> Unfortunately I am new to all this and would welcome any feedback on this
> error.
>
> Malcolm
>
>
>
>
Re: Validate logins with ASP, MS Access and Cookies error
Hi Steven, thank you for the reply. I am now getting this error
Microsoft VBScript compilation error '800a0400'
Expected statement
/vdateUsr.asp, line 13
Option Explicit
^Not sure why? can you help on this one also please. malcolm
"Steven Burn" <somewhere [at] in-time.invalid> wrote in message
news:uXlNxRKYGHA.1192 [at] TK2MSFTNGP04.phx.gbl...
> Give this a try ........
>
> '// BEGIN
> <% [at] Language="VBScript"%>
> <%Option Explicit%>
> <!-- METADATA TYPE="typelib" FILE="C:\Program Files\Common
> Files\System\ado\msado15.dll" -->
> <!-- #include file="Connectionstring.asp" -->
> <%
> ' /////////////////////////////////////
> ' login validation script
> ' © Matt Millross
> ' www.designplace.org
> ' free for use as long as copyright notice left intact
> ' For more scripts, visit www.designplace.org
> ' /////////////////////////////////////
>
> ' variables
> dim cnStr, rcSet, frmUsername, frmPassword, sqlStr
>
> 'store form input into variables
> frmUsername = Request.Form("UID")
> frmPassword = Request.Form("PWD")
>
> 'create connection and recordset objects
> Set cnStr = Server.CreateObject("ADODB.Connection")
> '// THIS IS NOT NEEDED!
> '// Set rcSet = Server.CreateObject("ADODB.Recordset")
>
> ' defining database connection (connectionstring.asp)
> cnStr.ConnectionString = path
> cnStr.Provider = provider
> cnStr.open
>
> ' execute sql and open as recordset
> '// sqlStr = "Select * From tblusers where username = '" _
> '// & Request.Form("UID") & "' and password = '" & Request.Form("PWD") &
> "'"
> '// You've already stored the user/pass into a local var - use them!
> '// and NEVER use "Select * ..."
> '//
> '// http://aspfaq.com/show.asp?id 96
>
> sqlStr = "Select username, password from tblUsers Where username = '" _
> & frmUsername & "' AND password = '" & frmPassword & "'"
>
> ' Opens the returned values from the SQL as a recordset,
> ' ready for iteration by ASP
> '// <<< LINE 53 >>> set rcSet = cnStr.Execute(sqlStr)
> ' validate variables against database
> // If (not rcSet.BOF) and (not rcSet.EOF) then
>
> '// Check before processing
> If Len(frmUsername) < 1 Then frmUsername = "NULL"
> If Len(frmPassword) < 1 Then frmPassword = "NULL"
> '// Then go...
> Set rcSet = cnStr.Execute(sqlStr)
>
> If NOT rcSet.EOF Then
> response.cookies("validated_user") = frmUsername
> response.write "<h1>Login successful!</h1>"
> '// Forget using rcSet.Fields, and just use rcSet
> '// directly
> response.write "<p>Welcome " & rcSet(1) & "</p>"
> else
> response.write "incorrect username and/or password"
> end if
>
> '// Don't forget to cleanup after yourself
> cnStr.Close: Set cnStr = Nothing
> Set rcSet = Nothing
> %>
> '// END
>
> --
> Regards
>
> Steven Burn
> Ur I.T. Mate Group
> www.it-mate.co.uk
>
> Keeping it FREE!
>
> "malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
> news:44410c1c$0$23181$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
>> Hi, while trying to validate username and password on login form I am
>> presented with the following error message
>>
>>
>> Microsoft JET Database Engine error '80040e10'
>>
>> No value given for one or more required parameters.
>>
>> /vdateUsr.asp, line 53
>>
>> The 2 fields within the database are text fields (UID) and (PWD) these
>> are
>> spelt correctly!
>>
>> This is the code that I am using:
>>
>> <% [at] Language=VBScript%>
>>
>> <!-- METADATA TYPE="typelib"
>> FILE="C:\Program Files\Common
>> Files\System\ado\msado15.dll" -->
>> <!-- #include file="Connectionstring.asp" -->
>>
>>
>> <%
>> ' /////////////////////////////////////
>> ' login validation script
>> ' © Matt Millross
>> ' www.designplace.org
>> ' free for use as long as copyright notice left intact
>> ' For more scripts, visit www.designplace.org
>> ' /////////////////////////////////////
>>
>> ' variables
>> dim cnStr
>> dim rcSet
>> dim frmUsername
>> dim frmPassword
>> dim sqlStr
>>
>> 'store form input into variables
>> frmUsername = Request.Form("UID")
>> frmPassword = Request.Form("PWD")
>>
>> 'create connection and recordset objects
>> Set cnStr = Server.CreateObject("ADODB.Connection")
>> Set rcSet = Server.CreateObject("ADODB.Recordset")
>>
>> ' defining database connection (connectionstring.asp)
>> cnStr.ConnectionString = path
>> cnStr.Provider = provider
>> cnStr.open
>>
>> ' execute sql and open as recordset
>> sqlStr = "Select * From tblusers where username = '" _
>> & Request.Form("UID") & "' and password = '" & Request.Form("PWD") &
> "'"
>>
>> ' Opens the returned values from the SQL as a recordset, ready for
> iteration
>> by ASP
>> <<< LINE 53 >>> set rcSet = cnStr.Execute(sqlStr)
>> ' validate variables against database
>> If (not rcSet.BOF) and (not rcSet.EOF) then
>> response.cookies("validated_user") = frmUsername
>> response.write "<h1>Login successful!</h1>"
>> response.write "<p>Welcome " & rcSet.fields(1) & "</p>"
>> else
>> response.write "incorrect username and/or password"
>> end if
>> %>
>>
>> Unfortunately I am new to all this and would welcome any feedback on this
>> error.
>>
>> Malcolm
>>
>>
>>
>>
>
>
Re: Validate logins with ASP, MS Access and Cookies error
Hi again steven, I removed <%Option Explicit%> and am now back to the
original error mesaage :(
Microsoft JET Database Engine error '80040e10'
No value given for one or more required parameters.
/vdateUsr.asp, line 63
again this is the same as before.
Regards Malcolm
"Steven Burn" <somewhere [at] in-time.invalid> wrote in message
news:uXlNxRKYGHA.1192 [at] TK2MSFTNGP04.phx.gbl...
> Give this a try ........
>
> '// BEGIN
> <% [at] Language="VBScript"%>
> <%Option Explicit%>
> <!-- METADATA TYPE="typelib" FILE="C:\Program Files\Common
> Files\System\ado\msado15.dll" -->
> <!-- #include file="Connectionstring.asp" -->
> <%
> ' /////////////////////////////////////
> ' login validation script
> ' © Matt Millross
> ' www.designplace.org
> ' free for use as long as copyright notice left intact
> ' For more scripts, visit www.designplace.org
> ' /////////////////////////////////////
>
> ' variables
> dim cnStr, rcSet, frmUsername, frmPassword, sqlStr
>
> 'store form input into variables
> frmUsername = Request.Form("UID")
> frmPassword = Request.Form("PWD")
>
> 'create connection and recordset objects
> Set cnStr = Server.CreateObject("ADODB.Connection")
> '// THIS IS NOT NEEDED!
> '// Set rcSet = Server.CreateObject("ADODB.Recordset")
>
> ' defining database connection (connectionstring.asp)
> cnStr.ConnectionString = path
> cnStr.Provider = provider
> cnStr.open
>
> ' execute sql and open as recordset
> '// sqlStr = "Select * From tblusers where username = '" _
> '// & Request.Form("UID") & "' and password = '" & Request.Form("PWD") &
> "'"
> '// You've already stored the user/pass into a local var - use them!
> '// and NEVER use "Select * ..."
> '//
> '// http://aspfaq.com/show.asp?id 96
>
> sqlStr = "Select username, password from tblUsers Where username = '" _
> & frmUsername & "' AND password = '" & frmPassword & "'"
>
> ' Opens the returned values from the SQL as a recordset,
> ' ready for iteration by ASP
> '// <<< LINE 53 >>> set rcSet = cnStr.Execute(sqlStr)
> ' validate variables against database
> // If (not rcSet.BOF) and (not rcSet.EOF) then
>
> '// Check before processing
> If Len(frmUsername) < 1 Then frmUsername = "NULL"
> If Len(frmPassword) < 1 Then frmPassword = "NULL"
> '// Then go...
> Set rcSet = cnStr.Execute(sqlStr)
>
> If NOT rcSet.EOF Then
> response.cookies("validated_user") = frmUsername
> response.write "<h1>Login successful!</h1>"
> '// Forget using rcSet.Fields, and just use rcSet
> '// directly
> response.write "<p>Welcome " & rcSet(1) & "</p>"
> else
> response.write "incorrect username and/or password"
> end if
>
> '// Don't forget to cleanup after yourself
> cnStr.Close: Set cnStr = Nothing
> Set rcSet = Nothing
> %>
> '// END
>
> --
> Regards
>
> Steven Burn
> Ur I.T. Mate Group
> www.it-mate.co.uk
>
> Keeping it FREE!
>
> "malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
> news:44410c1c$0$23181$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
>> Hi, while trying to validate username and password on login form I am
>> presented with the following error message
>>
>>
>> Microsoft JET Database Engine error '80040e10'
>>
>> No value given for one or more required parameters.
>>
>> /vdateUsr.asp, line 53
>>
>> The 2 fields within the database are text fields (UID) and (PWD) these
>> are
>> spelt correctly!
>>
>> This is the code that I am using:
>>
>> <% [at] Language=VBScript%>
>>
>> <!-- METADATA TYPE="typelib"
>> FILE="C:\Program Files\Common
>> Files\System\ado\msado15.dll" -->
>> <!-- #include file="Connectionstring.asp" -->
>>
>>
>> <%
>> ' /////////////////////////////////////
>> ' login validation script
>> ' © Matt Millross
>> ' www.designplace.org
>> ' free for use as long as copyright notice left intact
>> ' For more scripts, visit www.designplace.org
>> ' /////////////////////////////////////
>>
>> ' variables
>> dim cnStr
>> dim rcSet
>> dim frmUsername
>> dim frmPassword
>> dim sqlStr
>>
>> 'store form input into variables
>> frmUsername = Request.Form("UID")
>> frmPassword = Request.Form("PWD")
>>
>> 'create connection and recordset objects
>> Set cnStr = Server.CreateObject("ADODB.Connection")
>> Set rcSet = Server.CreateObject("ADODB.Recordset")
>>
>> ' defining database connection (connectionstring.asp)
>> cnStr.ConnectionString = path
>> cnStr.Provider = provider
>> cnStr.open
>>
>> ' execute sql and open as recordset
>> sqlStr = "Select * From tblusers where username = '" _
>> & Request.Form("UID") & "' and password = '" & Request.Form("PWD") &
> "'"
>>
>> ' Opens the returned values from the SQL as a recordset, ready for
> iteration
>> by ASP
>> <<< LINE 53 >>> set rcSet = cnStr.Execute(sqlStr)
>> ' validate variables against database
>> If (not rcSet.BOF) and (not rcSet.EOF) then
>> response.cookies("validated_user") = frmUsername
>> response.write "<h1>Login successful!</h1>"
>> response.write "<p>Welcome " & rcSet.fields(1) & "</p>"
>> else
>> response.write "incorrect username and/or password"
>> end if
>> %>
>>
>> Unfortunately I am new to all this and would welcome any feedback on this
>> error.
>>
>> Malcolm
>>
>>
>>
>>
>
>
Re: Validate logins with ASP, MS Access and Cookies error
Option Explicit should be the first line of script and above any
content that is sent to the client. What have you got in the preceding
12 lines?
--
Mike Brind
malcolm wrote:
> Hi Steven, thank you for the reply. I am now getting this error
>
>
> Microsoft VBScript compilation error '800a0400'
>
> Expected statement
>
> /vdateUsr.asp, line 13
>
> Option Explicit
> ^Not sure why? can you help on this one also please. malcolm
> "Steven Burn" <somewhere [at] in-time.invalid> wrote in message
> news:uXlNxRKYGHA.1192 [at] TK2MSFTNGP04.phx.gbl...
> > Give this a try ........
> >
> > '// BEGIN
> > <% [at] Language=3D"VBScript"%>
> > <%Option Explicit%>
> > <!-- METADATA TYPE=3D"typelib" FILE=3D"C:\Program Files\Common
> > Files\System\ado\msado15.dll" -->
> > <!-- #include file=3D"Connectionstring.asp" -->
> > <%
> > ' /////////////////////////////////////
> > ' login validation script
> > ' =A9 Matt Millross
> > ' www.designplace.org
> > ' free for use as long as copyright notice left intact
> > ' For more scripts, visit www.designplace.org
> > ' /////////////////////////////////////
> >
> > ' variables
> > dim cnStr, rcSet, frmUsername, frmPassword, sqlStr
> >
> > 'store form input into variables
> > frmUsername =3D Request.Form("UID")
> > frmPassword =3D Request.Form("PWD")
> >
> > 'create connection and recordset objects
> > Set cnStr =3D Server.CreateObject("ADODB.Connection")
> > '// THIS IS NOT NEEDED!
> > '// Set rcSet =3D Server.CreateObject("ADODB.Recordset")
> >
> > ' defining database connection (connectionstring.asp)
> > cnStr.ConnectionString =3D path
> > cnStr.Provider =3D provider
> > cnStr.open
> >
> > ' execute sql and open as recordset
> > '// sqlStr =3D "Select * From tblusers where username =3D '" _
> > '// & Request.Form("UID") & "' and password =3D '" & Request.Form("PW=
D") &
> > "'"
> > '// You've already stored the user/pass into a local var - use them!
> > '// and NEVER use "Select * ..."
> > '//
> > '// http://aspfaq.com/show.asp?id=3D2096
> >
> > sqlStr =3D "Select username, password from tblUsers Where username =3D =
'" _
> > & frmUsername & "' AND password =3D '" & frmPassword & "'"
> >
> > ' Opens the returned values from the SQL as a recordset,
> > ' ready for iteration by ASP
> > '// <<< LINE 53 >>> set rcSet =3D cnStr.Execute(sqlStr)
> > ' validate variables against database
> > // If (not rcSet.BOF) and (not rcSet.EOF) then
> >
> > '// Check before processing
> > If Len(frmUsername) < 1 Then frmUsername =3D "NULL"
> > If Len(frmPassword) < 1 Then frmPassword =3D "NULL"
> > '// Then go...
> > Set rcSet =3D cnStr.Execute(sqlStr)
> >
> > If NOT rcSet.EOF Then
> > response.cookies("validated_user") =3D frmUsername
> > response.write "<h1>Login successful!</h1>"
> > '// Forget using rcSet.Fields, and just use rcSet
> > '// directly
> > response.write "<p>Welcome " & rcSet(1) & "</p>"
> > else
> > response.write "incorrect username and/or password"
> > end if
> >
> > '// Don't forget to cleanup after yourself
> > cnStr.Close: Set cnStr =3D Nothing
> > Set rcSet =3D Nothing
> > %>
> > '// END
> >
> > --
> > Regards
> >
> > Steven Burn
> > Ur I.T. Mate Group
> > www.it-mate.co.uk
> >
> > Keeping it FREE!
> >
> > "malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
> > news:44410c1c$0$23181$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
> >> Hi, while trying to validate username and password on login form I am
> >> presented with the following error message
> >>
> >>
> >> Microsoft JET Database Engine error '80040e10'
> >>
> >> No value given for one or more required parameters.
> >>
> >> /vdateUsr.asp, line 53
> >>
> >> The 2 fields within the database are text fields (UID) and (PWD) these
> >> are
> >> spelt correctly!
> >>
> >> This is the code that I am using:
> >>
> >> <% [at] Language=3DVBScript%>
> >>
> >> <!-- METADATA TYPE=3D"typelib"
> >> FILE=3D"C:\Program Files\Common
> >> Files\System\ado\msado15.dll" -->
> >> <!-- #include file=3D"Connectionstring.asp" -->
> >>
> >>
> >> <%
> >> ' /////////////////////////////////////
> >> ' login validation script
> >> ' =A9 Matt Millross
> >> ' www.designplace.org
> >> ' free for use as long as copyright notice left intact
> >> ' For more scripts, visit www.designplace.org
> >> ' /////////////////////////////////////
> >>
> >> ' variables
> >> dim cnStr
> >> dim rcSet
> >> dim frmUsername
> >> dim frmPassword
> >> dim sqlStr
> >>
> >> 'store form input into variables
> >> frmUsername =3D Request.Form("UID")
> >> frmPassword =3D Request.Form("PWD")
> >>
> >> 'create connection and recordset objects
> >> Set cnStr =3D Server.CreateObject("ADODB.Connection")
> >> Set rcSet =3D Server.CreateObject("ADODB.Recordset")
> >>
> >> ' defining database connection (connectionstring.asp)
> >> cnStr.ConnectionString =3D path
> >> cnStr.Provider =3D provider
> >> cnStr.open
> >>
> >> ' execute sql and open as recordset
> >> sqlStr =3D "Select * From tblusers where username =3D '" _
> >> & Request.Form("UID") & "' and password =3D '" & Request.Form("PWD"=
) &
> > "'"
> >>
> >> ' Opens the returned values from the SQL as a recordset, ready for
> > iteration
> >> by ASP
> >> <<< LINE 53 >>> set rcSet =3D cnStr.Execute(sqlStr)
> >> ' validate variables against database
> >> If (not rcSet.BOF) and (not rcSet.EOF) then
> >> response.cookies("validated_user") =3D frmUsername
> >> response.write "<h1>Login successful!</h1>"
> >> response.write "<p>Welcome " & rcSet.fields(1) & "</p>"
> >> else
> >> response.write "incorrect username and/or password"
> >> end if
> >> %>
> >>
> >> Unfortunately I am new to all this and would welcome any feedback on t=
his
> >> error.
> >>
> >> Malcolm
> >>
> >>
> >>
> >>
> >
> >
Re: Validate logins with ASP, MS Access and Cookies error
Just before line 53, put these two lines in:
response.write sqlStr
response.end
What gets printed to you browser?
--
Mike Brind
malcolm wrote:
> Hi again steven, I removed <%Option Explicit%> and am now back to the
> original error mesaage :(
>
>
> Microsoft JET Database Engine error '80040e10'
>
> No value given for one or more required parameters.
>
> /vdateUsr.asp, line 63
>
> again this is the same as before.
>
> Regards Malcolm
>
> "Steven Burn" <somewhere [at] in-time.invalid> wrote in message
> news:uXlNxRKYGHA.1192 [at] TK2MSFTNGP04.phx.gbl...
> > Give this a try ........
> >
> > '// BEGIN
> > <% [at] Language=3D"VBScript"%>
> > <%Option Explicit%>
> > <!-- METADATA TYPE=3D"typelib" FILE=3D"C:\Program Files\Common
> > Files\System\ado\msado15.dll" -->
> > <!-- #include file=3D"Connectionstring.asp" -->
> > <%
> > ' /////////////////////////////////////
> > ' login validation script
> > ' =A9 Matt Millross
> > ' www.designplace.org
> > ' free for use as long as copyright notice left intact
> > ' For more scripts, visit www.designplace.org
> > ' /////////////////////////////////////
> >
> > ' variables
> > dim cnStr, rcSet, frmUsername, frmPassword, sqlStr
> >
> > 'store form input into variables
> > frmUsername =3D Request.Form("UID")
> > frmPassword =3D Request.Form("PWD")
> >
> > 'create connection and recordset objects
> > Set cnStr =3D Server.CreateObject("ADODB.Connection")
> > '// THIS IS NOT NEEDED!
> > '// Set rcSet =3D Server.CreateObject("ADODB.Recordset")
> >
> > ' defining database connection (connectionstring.asp)
> > cnStr.ConnectionString =3D path
> > cnStr.Provider =3D provider
> > cnStr.open
> >
> > ' execute sql and open as recordset
> > '// sqlStr =3D "Select * From tblusers where username =3D '" _
> > '// & Request.Form("UID") & "' and password =3D '" & Request.Form("PW=
D") &
> > "'"
> > '// You've already stored the user/pass into a local var - use them!
> > '// and NEVER use "Select * ..."
> > '//
> > '// http://aspfaq.com/show.asp?id=3D2096
> >
> > sqlStr =3D "Select username, password from tblUsers Where username =3D =
'" _
> > & frmUsername & "' AND password =3D '" & frmPassword & "'"
> >
> > ' Opens the returned values from the SQL as a recordset,
> > ' ready for iteration by ASP
> > '// <<< LINE 53 >>> set rcSet =3D cnStr.Execute(sqlStr)
> > ' validate variables against database
> > // If (not rcSet.BOF) and (not rcSet.EOF) then
> >
> > '// Check before processing
> > If Len(frmUsername) < 1 Then frmUsername =3D "NULL"
> > If Len(frmPassword) < 1 Then frmPassword =3D "NULL"
> > '// Then go...
> > Set rcSet =3D cnStr.Execute(sqlStr)
> >
> > If NOT rcSet.EOF Then
> > response.cookies("validated_user") =3D frmUsername
> > response.write "<h1>Login successful!</h1>"
> > '// Forget using rcSet.Fields, and just use rcSet
> > '// directly
> > response.write "<p>Welcome " & rcSet(1) & "</p>"
> > else
> > response.write "incorrect username and/or password"
> > end if
> >
> > '// Don't forget to cleanup after yourself
> > cnStr.Close: Set cnStr =3D Nothing
> > Set rcSet =3D Nothing
> > %>
> > '// END
> >
> > --
> > Regards
> >
> > Steven Burn
> > Ur I.T. Mate Group
> > www.it-mate.co.uk
> >
> > Keeping it FREE!
> >
> > "malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
> > news:44410c1c$0$23181$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
> >> Hi, while trying to validate username and password on login form I am
> >> presented with the following error message
> >>
> >>
> >> Microsoft JET Database Engine error '80040e10'
> >>
> >> No value given for one or more required parameters.
> >>
> >> /vdateUsr.asp, line 53
> >>
> >> The 2 fields within the database are text fields (UID) and (PWD) these
> >> are
> >> spelt correctly!
> >>
> >> This is the code that I am using:
> >>
> >> <% [at] Language=3DVBScript%>
> >>
> >> <!-- METADATA TYPE=3D"typelib"
> >> FILE=3D"C:\Program Files\Common
> >> Files\System\ado\msado15.dll" -->
> >> <!-- #include file=3D"Connectionstring.asp" -->
> >>
> >>
> >> <%
> >> ' /////////////////////////////////////
> >> ' login validation script
> >> ' =A9 Matt Millross
> >> ' www.designplace.org
> >> ' free for use as long as copyright notice left intact
> >> ' For more scripts, visit www.designplace.org
> >> ' /////////////////////////////////////
> >>
> >> ' variables
> >> dim cnStr
> >> dim rcSet
> >> dim frmUsername
> >> dim frmPassword
> >> dim sqlStr
> >>
> >> 'store form input into variables
> >> frmUsername =3D Request.Form("UID")
> >> frmPassword =3D Request.Form("PWD")
> >>
> >> 'create connection and recordset objects
> >> Set cnStr =3D Server.CreateObject("ADODB.Connection")
> >> Set rcSet =3D Server.CreateObject("ADODB.Recordset")
> >>
> >> ' defining database connection (connectionstring.asp)
> >> cnStr.ConnectionString =3D path
> >> cnStr.Provider =3D provider
> >> cnStr.open
> >>
> >> ' execute sql and open as recordset
> >> sqlStr =3D "Select * From tblusers where username =3D '" _
> >> & Request.Form("UID") & "' and password =3D '" & Request.Form("PWD"=
) &
> > "'"
> >>
> >> ' Opens the returned values from the SQL as a recordset, ready for
> > iteration
> >> by ASP
> >> <<< LINE 53 >>> set rcSet =3D cnStr.Execute(sqlStr)
> >> ' validate variables against database
> >> If (not rcSet.BOF) and (not rcSet.EOF) then
> >> response.cookies("validated_user") =3D frmUsername
> >> response.write "<h1>Login successful!</h1>"
> >> response.write "<p>Welcome " & rcSet.fields(1) & "</p>"
> >> else
> >> response.write "incorrect username and/or password"
> >> end if
> >> %>
> >>
> >> Unfortunately I am new to all this and would welcome any feedback on t=
his
> >> error.
> >>
> >> Malcolm
> >>
> >>
> >>
> >>
> >
> >
Re: Validate logins with ASP, MS Access and Cookies error
malcolm wrote:
> Hi, while trying to validate username and password on login form I am
> presented with the following error message
>
>
> Microsoft JET Database Engine error '80040e10'
>
> No value given for one or more required parameters.
>
> /vdateUsr.asp, line 53
>
> The 2 fields within the database are text fields (UID) and (PWD) these are
> spelt correctly!
>
<snip>
> sqlStr = "Select * From tblusers where username = '" _
> & Request.Form("UID") & "' and password = '" & Request.Form("PWD") & "'"
>
No - they're not spelt correctly. In your SQL statement you refer to
two fields called username and password, yet you said they are called
UID and PWD. Which is correct?
--
Mike Brind
Re: Validate logins with ASP, MS Access and Cookies error
UID and PWD are the 2 fields in my database that hold the information.
I have now changed the code
"Mike Brind" <paxtonend [at] hotmail.com> wrote in message
news:1145119070.271743.314040 [at] z34g2000cwc.googlegroups.com.. .
>
> malcolm wrote:
>> Hi, while trying to validate username and password on login form I am
>> presented with the following error message
>>
>>
>> Microsoft JET Database Engine error '80040e10'
>>
>> No value given for one or more required parameters.
>>
>> /vdateUsr.asp, line 53
>>
>> The 2 fields within the database are text fields (UID) and (PWD) these
>> are
>> spelt correctly!
>>
>
> <snip>
>> sqlStr = "Select * From tblusers where username = '" _
>> & Request.Form("UID") & "' and password = '" & Request.Form("PWD") &
>> "'"
>>
>
> No - they're not spelt correctly. In your SQL statement you refer to
> two fields called username and password, yet you said they are called
> UID and PWD. Which is correct?
>
> --
> Mike Brind
>
Re: Validate logins with ASP, MS Access and Cookies error
I am now presented with incorrect Username and/or Password. I have double
checked this.
I now have the following code in my page
<% [at] Language="VBScript"%>
<!-- METADATA TYPE="typelib" FILE="C:\Program Files\Common
Files\System\ado\msado15.dll" -->
<!-- #include file="Connectionstring.asp" -->
<%
' /////////////////////////////////////
' login validation script
' © Matt Millross
' www.designplace.org
' free for use as long as copyright notice left intact
' For more scripts, visit www.designplace.org
' /////////////////////////////////////
' variables
dim cnStr, rcSet, frmUID, frmPWD, sqlStr
'store form input into variables
frmUID = Request.Form("UID")
frmPWD = Request.Form("PWD")
'create connection and recordset objects
Set cnStr = Server.CreateObject("ADODB.Connection")
'// THIS IS NOT NEEDED!
'// Set rcSet = Server.CreateObject("ADODB.Recordset")
' defining database connection (connectionstring.asp)
cnStr.ConnectionString = path
cnStr.Provider = provider
cnStr.open
' execute sql and open as recordset
'// sqlStr = "Select * From tblusers where username = '" _
'// & Request.Form("UID") & "' and password = '" & Request.Form("PWD") &
"'"
'// You've already stored the user/pass into a local var - use them!
'// and NEVER use "Select * ..."
'//
'// http://aspfaq.com/show.asp?id 96
sqlStr = "Select * From tblusers where UID = '" _
& Request.Form("UID") & "' and PWD = '" & Request.Form("PWD") & "'"
' Opens the returned values from the SQL as a recordset,
' ready for iteration by ASP
'// <<< LINE 53 >>> set rcSet = cnStr.Execute(sqlStr)
' validate variables against database
// If (not rcSet.BOF) and (not rcSet.EOF) then
'// Check before processing
If Len(frmUsername) < 1 Then frmUsername = "NULL"
If Len(frmPassword) < 1 Then frmPassword = "NULL"
'// Then go...
Set rcSet = cnStr.Execute(sqlStr)
If NOT rcSet.EOF Then
response.cookies("validated_user") = frmUID
response.write "<h1>Login successful!</h1>"
'// Forget using rcSet.Fields, and just use rcSet
'// directly
response.write "<p>Welcome " & rcSet(1) & "</p>"
else
response.write "incorrect Username and/or Password"
end if
'// Don't forget to cleanup after yourself
cnStr.Close: Set cnStr = Nothing
Set rcSet = Nothing
%>
Regards
Malcolm
"malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
news:4441273b$0$23177$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
> UID and PWD are the 2 fields in my database that hold the information.
>
> I have now changed the code
>
> "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
> news:1145119070.271743.314040 [at] z34g2000cwc.googlegroups.com.. .
>>
>> malcolm wrote:
>>> Hi, while trying to validate username and password on login form I am
>>> presented with the following error message
>>>
>>>
>>> Microsoft JET Database Engine error '80040e10'
>>>
>>> No value given for one or more required parameters.
>>>
>>> /vdateUsr.asp, line 53
>>>
>>> The 2 fields within the database are text fields (UID) and (PWD) these
>>> are
>>> spelt correctly!
>>>
>>
>> <snip>
>>> sqlStr = "Select * From tblusers where username = '" _
>>> & Request.Form("UID") & "' and password = '" & Request.Form("PWD") &
>>> "'"
>>>
>>
>> No - they're not spelt correctly. In your SQL statement you refer to
>> two fields called username and password, yet you said they are called
>> UID and PWD. Which is correct?
>>
>> --
>> Mike Brind
>>
>
>
Re: Validate logins with ASP, MS Access and Cookies error
Login successful!
Fixed
my ISP had provided my with the wrong path to my database lol
thanks very much for all your work.
UK only
www.bankchargesrefunded.co.uk
"malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
news:4441284e$0$23185$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
>I am now presented with incorrect Username and/or Password. I have double
>checked this.
>
> I now have the following code in my page
>
> <% [at] Language="VBScript"%>
>
> <!-- METADATA TYPE="typelib" FILE="C:\Program Files\Common
> Files\System\ado\msado15.dll" -->
> <!-- #include file="Connectionstring.asp" -->
> <%
> ' /////////////////////////////////////
> ' login validation script
> ' © Matt Millross
> ' www.designplace.org
> ' free for use as long as copyright notice left intact
> ' For more scripts, visit www.designplace.org
> ' /////////////////////////////////////
>
> ' variables
> dim cnStr, rcSet, frmUID, frmPWD, sqlStr
>
> 'store form input into variables
> frmUID = Request.Form("UID")
> frmPWD = Request.Form("PWD")
>
> 'create connection and recordset objects
> Set cnStr = Server.CreateObject("ADODB.Connection")
> '// THIS IS NOT NEEDED!
> '// Set rcSet = Server.CreateObject("ADODB.Recordset")
>
> ' defining database connection (connectionstring.asp)
> cnStr.ConnectionString = path
> cnStr.Provider = provider
> cnStr.open
>
> ' execute sql and open as recordset
> '// sqlStr = "Select * From tblusers where username = '" _
> '// & Request.Form("UID") & "' and password = '" & Request.Form("PWD") &
> "'"
> '// You've already stored the user/pass into a local var - use them!
> '// and NEVER use "Select * ..."
> '//
> '// http://aspfaq.com/show.asp?id 96
>
> sqlStr = "Select * From tblusers where UID = '" _
> & Request.Form("UID") & "' and PWD = '" & Request.Form("PWD") & "'"
>
> ' Opens the returned values from the SQL as a recordset,
> ' ready for iteration by ASP
> '// <<< LINE 53 >>> set rcSet = cnStr.Execute(sqlStr)
> ' validate variables against database
> // If (not rcSet.BOF) and (not rcSet.EOF) then
>
> '// Check before processing
> If Len(frmUsername) < 1 Then frmUsername = "NULL"
> If Len(frmPassword) < 1 Then frmPassword = "NULL"
> '// Then go...
> Set rcSet = cnStr.Execute(sqlStr)
>
> If NOT rcSet.EOF Then
> response.cookies("validated_user") = frmUID
> response.write "<h1>Login successful!</h1>"
> '// Forget using rcSet.Fields, and just use rcSet
> '// directly
> response.write "<p>Welcome " & rcSet(1) & "</p>"
> else
> response.write "incorrect Username and/or Password"
> end if
>
> '// Don't forget to cleanup after yourself
> cnStr.Close: Set cnStr = Nothing
> Set rcSet = Nothing
> %>
>
>
> Regards
> Malcolm
>
>
> "malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
> news:4441273b$0$23177$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
>> UID and PWD are the 2 fields in my database that hold the information.
>>
>> I have now changed the code
>>
>> "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
>> news:1145119070.271743.314040 [at] z34g2000cwc.googlegroups.com.. .
>>>
>>> malcolm wrote:
>>>> Hi, while trying to validate username and password on login form I am
>>>> presented with the following error message
>>>>
>>>>
>>>> Microsoft JET Database Engine error '80040e10'
>>>>
>>>> No value given for one or more required parameters.
>>>>
>>>> /vdateUsr.asp, line 53
>>>>
>>>> The 2 fields within the database are text fields (UID) and (PWD) these
>>>> are
>>>> spelt correctly!
>>>>
>>>
>>> <snip>
>>>> sqlStr = "Select * From tblusers where username = '" _
>>>> & Request.Form("UID") & "' and password = '" & Request.Form("PWD") &
>>>> "'"
>>>>
>>>
>>> No - they're not spelt correctly. In your SQL statement you refer to
>>> two fields called username and password, yet you said they are called
>>> UID and PWD. Which is correct?
>>>
>>> --
>>> Mike Brind
>>>
>>
>>
>
>
Re: Validate logins with ASP, MS Access and Cookies error
Like you double checked the database table names? ;-)
Here's part of your code stripped of all the rubbish. At the point it
ends, insert the lines I have added and then run the code - seeing what
gets written to the browser:
<% [at] Language=3D"VBScript"%>
<!-- #include file=3D"Connectionstring.asp" -->
<%
dim cnStr, rcSet, frmUID, frmPWD, sqlStr
frmUID =3D Request.Form("UID")
frmPWD =3D Request.Form("PWD")
Set cnStr =3D Server.CreateObject("ADODB.Connection")
cnStr.ConnectionString =3D path
cnStr.Provider =3D provider
cnStr.open
sqlStr =3D "Select UID From tblusers where UID =3D '" _
& Request.Form("UID") & "' and PWD =3D '" & Request.Form("PWD") &
"'"
'insert the lines below here:
response.write sqlStr
response.end
%>
And see if the values you expect to be passed are indeed the ones that
appear.
--
Mike Brind
malcolm wrote:
> I am now presented with incorrect Username and/or Password. I have double
> checked this.
>
> I now have the following code in my page
>
> <% [at] Language=3D"VBScript"%>
>
> <!-- METADATA TYPE=3D"typelib" FILE=3D"C:\Program Files\Common
> Files\System\ado\msado15.dll" -->
> <!-- #include file=3D"Connectionstring.asp" -->
> <%
> ' /////////////////////////////////////
> ' login validation script
> ' =A9 Matt Millross
> ' www.designplace.org
> ' free for use as long as copyright notice left intact
> ' For more scripts, visit www.designplace.org
> ' /////////////////////////////////////
>
> ' variables
> dim cnStr, rcSet, frmUID, frmPWD, sqlStr
>
> 'store form input into variables
> frmUID =3D Request.Form("UID")
> frmPWD =3D Request.Form("PWD")
>
> 'create connection and recordset objects
> Set cnStr =3D Server.CreateObject("ADODB.Connection")
> '// THIS IS NOT NEEDED!
> '// Set rcSet =3D Server.CreateObject("ADODB.Recordset")
>
> ' defining database connection (connectionstring.asp)
> cnStr.ConnectionString =3D path
> cnStr.Provider =3D provider
> cnStr.open
>
> ' execute sql and open as recordset
> '// sqlStr =3D "Select * From tblusers where username =3D '" _
> '// & Request.Form("UID") & "' and password =3D '" & Request.Form("PWD"=
) &
> "'"
> '// You've already stored the user/pass into a local var - use them!
> '// and NEVER use "Select * ..."
> '//
> '// http://aspfaq.com/show.asp?id=3D2096
>
> sqlStr =3D "Select * From tblusers where UID =3D '" _
> & Request.Form("UID") & "' and PWD =3D '" & Request.Form("PWD") & "'"
>
> ' Opens the returned values from the SQL as a recordset,
> ' ready for iteration by ASP
> '// <<< LINE 53 >>> set rcSet =3D cnStr.Execute(sqlStr)
> ' validate variables against database
> // If (not rcSet.BOF) and (not rcSet.EOF) then
>
> '// Check before processing
> If Len(frmUsername) < 1 Then frmUsername =3D "NULL"
> If Len(frmPassword) < 1 Then frmPassword =3D "NULL"
> '// Then go...
> Set rcSet =3D cnStr.Execute(sqlStr)
>
> If NOT rcSet.EOF Then
> response.cookies("validated_user") =3D frmUID
> response.write "<h1>Login successful!</h1>"
> '// Forget using rcSet.Fields, and just use rcSet
> '// directly
> response.write "<p>Welcome " & rcSet(1) & "</p>"
> else
> response.write "incorrect Username and/or Password"
> end if
>
> '// Don't forget to cleanup after yourself
> cnStr.Close: Set cnStr =3D Nothing
> Set rcSet =3D Nothing
> %>
>
>
> Regards
> Malcolm
>
>
> "malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
> news:4441273b$0$23177$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
> > UID and PWD are the 2 fields in my database that hold the information.
> >
> > I have now changed the code
> >
> > "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
> > news:1145119070.271743.314040 [at] z34g2000cwc.googlegroups.com.. .
> >>
> >> malcolm wrote:
> >>> Hi, while trying to validate username and password on login form I am
> >>> presented with the following error message
> >>>
> >>>
> >>> Microsoft JET Database Engine error '80040e10'
> >>>
> >>> No value given for one or more required parameters.
> >>>
> >>> /vdateUsr.asp, line 53
> >>>
> >>> The 2 fields within the database are text fields (UID) and (PWD) these
> >>> are
> >>> spelt correctly!
> >>>
> >>
> >> <snip>
> >>> sqlStr =3D "Select * From tblusers where username =3D '" _
> >>> & Request.Form("UID") & "' and password =3D '" & Request.Form("PWD=
") &
> >>> "'"
> >>>
> >>
> >> No - they're not spelt correctly. In your SQL statement you refer to
> >> two fields called username and password, yet you said they are called
> >> UID and PWD. Which is correct?
> >>
> >> --
> >> Mike Brind
> >>
> >
> >
Re: Validate logins with ASP, MS Access and Cookies error
Change;
sqlStr = "Select * From tblusers where UID = '" _
& Request.Form("UID") & "' and PWD = '" & Request.Form("PWD") & "'"
' Opens the returned values from the SQL as a recordset,
' ready for iteration by ASP
'// <<< LINE 53 >>> set rcSet = cnStr.Execute(sqlStr)
' validate variables against database
// If (not rcSet.BOF) and (not rcSet.EOF) then
'// Check before processing
If Len(frmUsername) < 1 Then frmUsername = "NULL"
If Len(frmPassword) < 1 Then frmPassword = "NULL"
To;
'// Check before processing
If Len(frmUsername) < 1 Then frmUsername = "NULL"
If Len(frmPassword) < 1 Then frmPassword = "NULL"
Response.Write "<b><i>DEBUG</i><b><br>Username: " _
& frmUID & "<br>Password: " & frmPWD
sqlStr = "Select * From tblusers where UID = '" _
& frmUID & "' and PWD = '" & frmPWD & "'"
' Opens the returned values from the SQL as a recordset,
' ready for iteration by ASP
'// <<< LINE 53 >>> set rcSet = cnStr.Execute(sqlStr)
' validate variables against database
// If (not rcSet.BOF) and (not rcSet.EOF) then
--
Regards
Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk
Keeping it FREE!
"malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
news:4441284e$0$23185$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
> I am now presented with incorrect Username and/or Password. I have double
> checked this.
>
> I now have the following code in my page
>
> <% [at] Language="VBScript"%>
>
> <!-- METADATA TYPE="typelib" FILE="C:\Program Files\Common
> Files\System\ado\msado15.dll" -->
> <!-- #include file="Connectionstring.asp" -->
> <%
> ' /////////////////////////////////////
> ' login validation script
> ' © Matt Millross
> ' www.designplace.org
> ' free for use as long as copyright notice left intact
> ' For more scripts, visit www.designplace.org
> ' /////////////////////////////////////
>
> ' variables
> dim cnStr, rcSet, frmUID, frmPWD, sqlStr
>
> 'store form input into variables
> frmUID = Request.Form("UID")
> frmPWD = Request.Form("PWD")
>
> 'create connection and recordset objects
> Set cnStr = Server.CreateObject("ADODB.Connection")
> '// THIS IS NOT NEEDED!
> '// Set rcSet = Server.CreateObject("ADODB.Recordset")
>
> ' defining database connection (connectionstring.asp)
> cnStr.ConnectionString = path
> cnStr.Provider = provider
> cnStr.open
>
> ' execute sql and open as recordset
> '// sqlStr = "Select * From tblusers where username = '" _
> '// & Request.Form("UID") & "' and password = '" & Request.Form("PWD") &
> "'"
> '// You've already stored the user/pass into a local var - use them!
> '// and NEVER use "Select * ..."
> '//
> '// http://aspfaq.com/show.asp?id 96
>
> sqlStr = "Select * From tblusers where UID = '" _
> & Request.Form("UID") & "' and PWD = '" & Request.Form("PWD") & "'"
>
> ' Opens the returned values from the SQL as a recordset,
> ' ready for iteration by ASP
> '// <<< LINE 53 >>> set rcSet = cnStr.Execute(sqlStr)
> ' validate variables against database
> // If (not rcSet.BOF) and (not rcSet.EOF) then
>
> '// Check before processing
> If Len(frmUsername) < 1 Then frmUsername = "NULL"
> If Len(frmPassword) < 1 Then frmPassword = "NULL"
> '// Then go...
> Set rcSet = cnStr.Execute(sqlStr)
>
> If NOT rcSet.EOF Then
> response.cookies("validated_user") = frmUID
> response.write "<h1>Login successful!</h1>"
> '// Forget using rcSet.Fields, and just use rcSet
> '// directly
> response.write "<p>Welcome " & rcSet(1) & "</p>"
> else
> response.write "incorrect Username and/or Password"
> end if
>
> '// Don't forget to cleanup after yourself
> cnStr.Close: Set cnStr = Nothing
> Set rcSet = Nothing
> %>
>
>
> Regards
> Malcolm
>
>
> "malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
> news:4441273b$0$23177$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
> > UID and PWD are the 2 fields in my database that hold the information.
> >
> > I have now changed the code
> >
> > "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
> > news:1145119070.271743.314040 [at] z34g2000cwc.googlegroups.com.. .
> >>
> >> malcolm wrote:
> >>> Hi, while trying to validate username and password on login form I am
> >>> presented with the following error message
> >>>
> >>>
> >>> Microsoft JET Database Engine error '80040e10'
> >>>
> >>> No value given for one or more required parameters.
> >>>
> >>> /vdateUsr.asp, line 53
> >>>
> >>> The 2 fields within the database are text fields (UID) and (PWD) these
> >>> are
> >>> spelt correctly!
> >>>
> >>
> >> <snip>
> >>> sqlStr = "Select * From tblusers where username = '" _
> >>> & Request.Form("UID") & "' and password = '" & Request.Form("PWD")
&
> >>> "'"
> >>>
> >>
> >> No - they're not spelt correctly. In your SQL statement you refer to
> >> two fields called username and password, yet you said they are called
> >> UID and PWD. Which is correct?
> >>
> >> --
> >> Mike Brind
> >>
> >
> >
>
>
Re: Validate logins with ASP, MS Access and Cookies error
Thanks Guys, i have now cleaned up the code and it is working ok. Just one
thing I want to ask! on the login successful page it shows the username aas
typed into the form UID field.. what I would like to do now is actully
return another column from the database that stores the users 1st name :-)
any tips
here is the code I am using now. :-)
<% [at] Language="VBScript"%>
<!-- METADATA TYPE="typelib" FILE="C:\Program Files\Common
Files\System\ado\msado15.dll" -->
<!-- #include file="Connectionstring.asp" -->
<%
' variables
dim cnStr, rcSet, frmUID, frmPWD, sqlStr
'store form input into variables
frmUID = Request.Form("UID")
frmPWD = Request.Form("PWD")
'create connection and recordset objects
Set cnStr = Server.CreateObject("ADODB.Connection")
' defining database connection (connectionstring.asp)
cnStr.ConnectionString = path
cnStr.Provider = provider
cnStr.open
' execute sql and open as recordset
sqlStr = "Select * From tblusers where UID = '" _
& Request.Form("UID") & "' and PWD = '" & Request.Form("PWD") & "'"
' Opens the returned values from the SQL as a recordset,
' ready for iteration by ASP
' validate variables against database
// If (not rcSet.BOF) and (not rcSet.EOF) then
If Len(frmUID) < 1 Then frmUID = "NULL"
If Len(frmPWD) < 1 Then frmPWD = "NULL"
Set rcSet = cnStr.Execute(sqlStr)
If NOT rcSet.EOF Then
response.cookies("validated_user") = frmUID
response.write "<h1>Login successful!</h1>"
response.write "<p>Welcome " & rcSet(0) & "</p>"
else
response.write "Incorrect Username and/or Password"
end if
cnStr.Close: Set cnStr = Nothing
Set rcSet = Nothing
%>
I had to change this code
response.write "<p>Welcome " & rcSet(1) & "</p>"
to this code
response.write "<p>Welcome " & rcSet(0) & "</p>"
so that it would display the username and not the password ;-)
not bad for a guess. :-)
Regards
Malcolm
"Steven Burn" <somewhere [at] in-time.invalid> wrote in message
news:e%237BQOLYGHA.3448 [at] TK2MSFTNGP04.phx.gbl...
> Change;
>
> sqlStr = "Select * From tblusers where UID = '" _
> & Request.Form("UID") & "' and PWD = '" & Request.Form("PWD") & "'"
>
> ' Opens the returned values from the SQL as a recordset,
> ' ready for iteration by ASP
> '// <<< LINE 53 >>> set rcSet = cnStr.Execute(sqlStr)
> ' validate variables against database
> // If (not rcSet.BOF) and (not rcSet.EOF) then
>
> '// Check before processing
> If Len(frmUsername) < 1 Then frmUsername = "NULL"
> If Len(frmPassword) < 1 Then frmPassword = "NULL"
>
> To;
>
> '// Check before processing
> If Len(frmUsername) < 1 Then frmUsername = "NULL"
> If Len(frmPassword) < 1 Then frmPassword = "NULL"
> Response.Write "<b><i>DEBUG</i><b><br>Username: " _
> & frmUID & "<br>Password: " & frmPWD
> sqlStr = "Select * From tblusers where UID = '" _
> & frmUID & "' and PWD = '" & frmPWD & "'"
>
> ' Opens the returned values from the SQL as a recordset,
> ' ready for iteration by ASP
> '// <<< LINE 53 >>> set rcSet = cnStr.Execute(sqlStr)
> ' validate variables against database
> // If (not rcSet.BOF) and (not rcSet.EOF) then
>
> --
> Regards
>
> Steven Burn
> Ur I.T. Mate Group
> www.it-mate.co.uk
>
> Keeping it FREE!
>
> "malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
> news:4441284e$0$23185$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
>> I am now presented with incorrect Username and/or Password. I have double
>> checked this.
>>
>> I now have the following code in my page
>>
>> <% [at] Language="VBScript"%>
>>
>> <!-- METADATA TYPE="typelib" FILE="C:\Program Files\Common
>> Files\System\ado\msado15.dll" -->
>> <!-- #include file="Connectionstring.asp" -->
>> <%
>> ' /////////////////////////////////////
>> ' login validation script
>> ' © Matt Millross
>> ' www.designplace.org
>> ' free for use as long as copyright notice left intact
>> ' For more scripts, visit www.designplace.org
>> ' /////////////////////////////////////
>>
>> ' variables
>> dim cnStr, rcSet, frmUID, frmPWD, sqlStr
>>
>> 'store form input into variables
>> frmUID = Request.Form("UID")
>> frmPWD = Request.Form("PWD")
>>
>> 'create connection and recordset objects
>> Set cnStr = Server.CreateObject("ADODB.Connection")
>> '// THIS IS NOT NEEDED!
>> '// Set rcSet = Server.CreateObject("ADODB.Recordset")
>>
>> ' defining database connection (connectionstring.asp)
>> cnStr.ConnectionString = path
>> cnStr.Provider = provider
>> cnStr.open
>>
>> ' execute sql and open as recordset
>> '// sqlStr = "Select * From tblusers where username = '" _
>> '// & Request.Form("UID") & "' and password = '" & Request.Form("PWD")
>> &
>> "'"
>> '// You've already stored the user/pass into a local var - use them!
>> '// and NEVER use "Select * ..."
>> '//
>> '// http://aspfaq.com/show.asp?id 96
>>
>> sqlStr = "Select * From tblusers where UID = '" _
>> & Request.Form("UID") & "' and PWD = '" & Request.Form("PWD") & "'"
>>
>> ' Opens the returned values from the SQL as a recordset,
>> ' ready for iteration by ASP
>> '// <<< LINE 53 >>> set rcSet = cnStr.Execute(sqlStr)
>> ' validate variables against database
>> // If (not rcSet.BOF) and (not rcSet.EOF) then
>>
>> '// Check before processing
>> If Len(frmUsername) < 1 Then frmUsername = "NULL"
>> If Len(frmPassword) < 1 Then frmPassword = "NULL"
>> '// Then go...
>> Set rcSet = cnStr.Execute(sqlStr)
>>
>> If NOT rcSet.EOF Then
>> response.cookies("validated_user") = frmUID
>> response.write "<h1>Login successful!</h1>"
>> '// Forget using rcSet.Fields, and just use rcSet
>> '// directly
>> response.write "<p>Welcome " & rcSet(1) & "</p>"
>> else
>> response.write "incorrect Username and/or Password"
>> end if
>>
>> '// Don't forget to cleanup after yourself
>> cnStr.Close: Set cnStr = Nothing
>> Set rcSet = Nothing
>> %>
>>
>>
>> Regards
>> Malcolm
>>
>>
>> "malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
>> news:4441273b$0$23177$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
>> > UID and PWD are the 2 fields in my database that hold the information.
>> >
>> > I have now changed the code
>> >
>> > "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
>> > news:1145119070.271743.314040 [at] z34g2000cwc.googlegroups.com.. .
>> >>
>> >> malcolm wrote:
>> >>> Hi, while trying to validate username and password on login form I am
>> >>> presented with the following error message
>> >>>
>> >>>
>> >>> Microsoft JET Database Engine error '80040e10'
>> >>>
>> >>> No value given for one or more required parameters.
>> >>>
>> >>> /vdateUsr.asp, line 53
>> >>>
>> >>> The 2 fields within the database are text fields (UID) and (PWD)
>> >>> these
>> >>> are
>> >>> spelt correctly!
>> >>>
>> >>
>> >> <snip>
>> >>> sqlStr = "Select * From tblusers where username = '" _
>> >>> & Request.Form("UID") & "' and password = '" & Request.Form("PWD")
> &
>> >>> "'"
>> >>>
>> >>
>> >> No - they're not spelt correctly. In your SQL statement you refer to
>> >> two fields called username and password, yet you said they are called
>> >> UID and PWD. Which is correct?
>> >>
>> >> --
>> >> Mike Brind
>> >>
>> >
>> >
>>
>>
>
>
Re: Validate logins with ASP, MS Access and Cookies error
Which field in the database holds the user's first name? And what type
of database are you using?
--
Mike Brind
malcolm wrote:
> Thanks Guys, i have now cleaned up the code and it is working ok. Just one
> thing I want to ask! on the login successful page it shows the username a=
as
> typed into the form UID field.. what I would like to do now is actully
> return another column from the database that stores the users 1st name :-)
>
> any tips
>
> here is the code I am using now. :-)
>
> <% [at] Language=3D"VBScript"%>
>
> <!-- METADATA TYPE=3D"typelib" FILE=3D"C:\Program Files\Common
> Files\System\ado\msado15.dll" -->
> <!-- #include file=3D"Connectionstring.asp" -->
> <%
>
> ' variables
> dim cnStr, rcSet, frmUID, frmPWD, sqlStr
>
> 'store form input into variables
> frmUID =3D Request.Form("UID")
> frmPWD =3D Request.Form("PWD")
>
> 'create connection and recordset objects
> Set cnStr =3D Server.CreateObject("ADODB.Connection")
>
> ' defining database connection (connectionstring.asp)
> cnStr.ConnectionString =3D path
> cnStr.Provider =3D provider
> cnStr.open
>
> ' execute sql and open as recordset
>
> sqlStr =3D "Select * From tblusers where UID =3D '" _
> & Request.Form("UID") & "' and PWD =3D '" & Request.Form("PWD") & "'"
>
> ' Opens the returned values from the SQL as a recordset,
> ' ready for iteration by ASP
> ' validate variables against database
> // If (not rcSet.BOF) and (not rcSet.EOF) then
>
> If Len(frmUID) < 1 Then frmUID =3D "NULL"
> If Len(frmPWD) < 1 Then frmPWD =3D "NULL"
>
> Set rcSet =3D cnStr.Execute(sqlStr)
>
> If NOT rcSet.EOF Then
> response.cookies("validated_user") =3D frmUID
> response.write "<h1>Login successful!</h1>"
>
> response.write "<p>Welcome " & rcSet(0) & "</p>"
> else
> response.write "Incorrect Username and/or Password"
> end if
>
> cnStr.Close: Set cnStr =3D Nothing
> Set rcSet =3D Nothing
> %>
>
> I had to change this code
> response.write "<p>Welcome " & rcSet(1) & "</p>"
> to this code
> response.write "<p>Welcome " & rcSet(0) & "</p>"
> so that it would display the username and not the password ;-)
> not bad for a guess. :-)
>
> Regards
> Malcolm
>
>
> "Steven Burn" <somewhere [at] in-time.invalid> wrote in message
> news:e%237BQOLYGHA.3448 [at] TK2MSFTNGP04.phx.gbl...
> > Change;
> >
> > sqlStr =3D "Select * From tblusers where UID =3D '" _
> > & Request.Form("UID") & "' and PWD =3D '" & Request.Form("PWD") & "=
'"
> >
> > ' Opens the returned values from the SQL as a recordset,
> > ' ready for iteration by ASP
> > '// <<< LINE 53 >>> set rcSet =3D cnStr.Execute(sqlStr)
> > ' validate variables against database
> > // If (not rcSet.BOF) and (not rcSet.EOF) then
> >
> > '// Check before processing
> > If Len(frmUsername) < 1 Then frmUsername =3D "NULL"
> > If Len(frmPassword) < 1 Then frmPassword =3D "NULL"
> >
> > To;
> >
> > '// Check before processing
> > If Len(frmUsername) < 1 Then frmUsername =3D "NULL"
> > If Len(frmPassword) < 1 Then frmPassword =3D "NULL"
> > Response.Write "<b><i>DEBUG</i><b><br>Username: " _
> > & frmUID & "<br>Password: " & frmPWD
> > sqlStr =3D "Select * From tblusers where UID =3D '" _
> > & frmUID & "' and PWD =3D '" & frmPWD & "'"
> >
> > ' Opens the returned values from the SQL as a recordset,
> > ' ready for iteration by ASP
> > '// <<< LINE 53 >>> set rcSet =3D cnStr.Execute(sqlStr)
> > ' validate variables against database
> > // If (not rcSet.BOF) and (not rcSet.EOF) then
> >
> > --
> > Regards
> >
> > Steven Burn
> > Ur I.T. Mate Group
> > www.it-mate.co.uk
> >
> > Keeping it FREE!
> >
> > "malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
> > news:4441284e$0$23185$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
> >> I am now presented with incorrect Username and/or Password. I have dou=
ble
> >> checked this.
> >>
> >> I now have the following code in my page
> >>
> >> <% [at] Language=3D"VBScript"%>
> >>
> >> <!-- METADATA TYPE=3D"typelib" FILE=3D"C:\Program Files\Common
> >> Files\System\ado\msado15.dll" -->
> >> <!-- #include file=3D"Connectionstring.asp" -->
> >> <%
> >> ' /////////////////////////////////////
> >> ' login validation script
> >> ' =A9 Matt Millross
> >> ' www.designplace.org
> >> ' free for use as long as copyright notice left intact
> >> ' For more scripts, visit www.designplace.org
> >> ' /////////////////////////////////////
> >>
> >> ' variables
> >> dim cnStr, rcSet, frmUID, frmPWD, sqlStr
> >>
> >> 'store form input into variables
> >> frmUID =3D Request.Form("UID")
> >> frmPWD =3D Request.Form("PWD")
> >>
> >> 'create connection and recordset objects
> >> Set cnStr =3D Server.CreateObject("ADODB.Connection")
> >> '// THIS IS NOT NEEDED!
> >> '// Set rcSet =3D Server.CreateObject("ADODB.Recordset")
> >>
> >> ' defining database connection (connectionstring.asp)
> >> cnStr.ConnectionString =3D path
> >> cnStr.Provider =3D provider
> >> cnStr.open
> >>
> >> ' execute sql and open as recordset
> >> '// sqlStr =3D "Select * From tblusers where username =3D '" _
> >> '// & Request.Form("UID") & "' and password =3D '" & Request.Form("P=
WD")
> >> &
> >> "'"
> >> '// You've already stored the user/pass into a local var - use them!
> >> '// and NEVER use "Select * ..."
> >> '//
> >> '// http://aspfaq.com/show.asp?id=3D2096
> >>
> >> sqlStr =3D "Select * From tblusers where UID =3D '" _
> >> & Request.Form("UID") & "' and PWD =3D '" & Request.Form("PWD") &=
"'"
> >>
> >> ' Opens the returned values from the SQL as a recordset,
> >> ' ready for iteration by ASP
> >> '// <<< LINE 53 >>> set rcSet =3D cnStr.Execute(sqlStr)
> >> ' validate variables against database
> >> // If (not rcSet.BOF) and (not rcSet.EOF) then
> >>
> >> '// Check before processing
> >> If Len(frmUsername) < 1 Then frmUsername =3D "NULL"
> >> If Len(frmPassword) < 1 Then frmPassword =3D "NULL"
> >> '// Then go...
> >> Set rcSet =3D cnStr.Execute(sqlStr)
> >>
> >> If NOT rcSet.EOF Then
> >> response.cookies("validated_user") =3D frmUID
> >> response.write "<h1>Login successful!</h1>"
> >> '// Forget using rcSet.Fields, and just use rcSet
> >> '// directly
> >> response.write "<p>Welcome " & rcSet(1) & "</p>"
> >> else
> >> response.write "incorrect Username and/or Password"
> >> end if
> >>
> >> '// Don't forget to cleanup after yourself
> >> cnStr.Close: Set cnStr =3D Nothing
> >> Set rcSet =3D Nothing
> >> %>
> >>
> >>
> >> Regards
> >> Malcolm
> >>
> >>
> >> "malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
> >> news:4441273b$0$23177$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
> >> > UID and PWD are the 2 fields in my database that hold the informatio=
n=2E
> >> >
> >> > I have now changed the code
> >> >
> >> > "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
> >> > news:1145119070.271743.314040 [at] z34g2000cwc.googlegroups.com.. .
> >> >>
> >> >> malcolm wrote:
> >> >>> Hi, while trying to validate username and password on login form I=
am
> >> >>> presented with the following error message
> >> >>>
> >> >>>
> >> >>> Microsoft JET Database Engine error '80040e10'
> >> >>>
> >> >>> No value given for one or more required parameters.
> >> >>>
> >> >>> /vdateUsr.asp, line 53
> >> >>>
> >> >>> The 2 fields within the database are text fields (UID) and (PWD)
> >> >>> these
> >> >>> are
> >> >>> spelt correctly!
> >> >>>
> >> >>
> >> >> <snip>
> >> >>> sqlStr =3D "Select * From tblusers where username =3D '" _
> >> >>> & Request.Form("UID") & "' and password =3D '" & Request.Form("=
PWD")
> > &
> >> >>> "'"
> >> >>>
> >> >>
> >> >> No - they're not spelt correctly. In your SQL statement you refer=
to
> >> >> two fields called username and password, yet you said they are call=
ed
> >> >> UID and PWD. Which is correct?
> >> >>
> >> >> --
> >> >> Mike Brind
> >> >>
> >> >
> >> >
> >>
> >>
> >
> >
Re: Validate logins with ASP, MS Access and Cookies error
AGAIN, stop using "Select *" !!!!!!
http://aspfaq.com/show.asp?id 96
As for returning the users actual name, just select it from the DB;
strSQL = "Select UsersName, UID From tblUsers Where UID = '" & strUID & "'"
Where "UsersName" is the name of the field that holds the data you require.
--
Regards
Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk
Keeping it FREE!
"malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
news:444133fc$0$23199$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
> Thanks Guys, i have now cleaned up the code and it is working ok. Just one
> thing I want to ask! on the login successful page it shows the username
aas
> typed into the form UID field.. what I would like to do now is actully
> return another column from the database that stores the users 1st name :-)
>
> any tips
>
> here is the code I am using now. :-)
>
> <% [at] Language="VBScript"%>
>
> <!-- METADATA TYPE="typelib" FILE="C:\Program Files\Common
> Files\System\ado\msado15.dll" -->
> <!-- #include file="Connectionstring.asp" -->
> <%
>
> ' variables
> dim cnStr, rcSet, frmUID, frmPWD, sqlStr
>
> 'store form input into variables
> frmUID = Request.Form("UID")
> frmPWD = Request.Form("PWD")
>
> 'create connection and recordset objects
> Set cnStr = Server.CreateObject("ADODB.Connection")
>
> ' defining database connection (connectionstring.asp)
> cnStr.ConnectionString = path
> cnStr.Provider = provider
> cnStr.open
>
> ' execute sql and open as recordset
>
> sqlStr = "Select * From tblusers where UID = '" _
> & Request.Form("UID") & "' and PWD = '" & Request.Form("PWD") & "'"
>
> ' Opens the returned values from the SQL as a recordset,
> ' ready for iteration by ASP
> ' validate variables against database
> // If (not rcSet.BOF) and (not rcSet.EOF) then
>
> If Len(frmUID) < 1 Then frmUID = "NULL"
> If Len(frmPWD) < 1 Then frmPWD = "NULL"
>
> Set rcSet = cnStr.Execute(sqlStr)
>
> If NOT rcSet.EOF Then
> response.cookies("validated_user") = frmUID
> response.write "<h1>Login successful!</h1>"
>
> response.write "<p>Welcome " & rcSet(0) & "</p>"
> else
> response.write "Incorrect Username and/or Password"
> end if
>
> cnStr.Close: Set cnStr = Nothing
> Set rcSet = Nothing
> %>
>
> I had to change this code
> response.write "<p>Welcome " & rcSet(1) & "</p>"
> to this code
> response.write "<p>Welcome " & rcSet(0) & "</p>"
> so that it would display the username and not the password ;-)
> not bad for a guess. :-)
>
> Regards
> Malcolm
>
>
> "Steven Burn" <somewhere [at] in-time.invalid> wrote in message
> news:e%237BQOLYGHA.3448 [at] TK2MSFTNGP04.phx.gbl...
> > Change;
> >
> > sqlStr = "Select * From tblusers where UID = '" _
> > & Request.Form("UID") & "' and PWD = '" & Request.Form("PWD") & "'"
> >
> > ' Opens the returned values from the SQL as a recordset,
> > ' ready for iteration by ASP
> > '// <<< LINE 53 >>> set rcSet = cnStr.Execute(sqlStr)
> > ' validate variables against database
> > // If (not rcSet.BOF) and (not rcSet.EOF) then
> >
> > '// Check before processing
> > If Len(frmUsername) < 1 Then frmUsername = "NULL"
> > If Len(frmPassword) < 1 Then frmPassword = "NULL"
> >
> > To;
> >
> > '// Check before processing
> > If Len(frmUsername) < 1 Then frmUsername = "NULL"
> > If Len(frmPassword) < 1 Then frmPassword = "NULL"
> > Response.Write "<b><i>DEBUG</i><b><br>Username: " _
> > & frmUID & "<br>Password: " & frmPWD
> > sqlStr = "Select * From tblusers where UID = '" _
> > & frmUID & "' and PWD = '" & frmPWD & "'"
> >
> > ' Opens the returned values from the SQL as a recordset,
> > ' ready for iteration by ASP
> > '// <<< LINE 53 >>> set rcSet = cnStr.Execute(sqlStr)
> > ' validate variables against database
> > // If (not rcSet.BOF) and (not rcSet.EOF) then
> >
> > --
> > Regards
> >
> > Steven Burn
> > Ur I.T. Mate Group
> > www.it-mate.co.uk
> >
> > Keeping it FREE!
> >
> > "malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
> > news:4441284e$0$23185$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
> >> I am now presented with incorrect Username and/or Password. I have
double
> >> checked this.
> >>
> >> I now have the following code in my page
> >>
> >> <% [at] Language="VBScript"%>
> >>
> >> <!-- METADATA TYPE="typelib" FILE="C:\Program Files\Common
> >> Files\System\ado\msado15.dll" -->
> >> <!-- #include file="Connectionstring.asp" -->
> >> <%
> >> ' /////////////////////////////////////
> >> ' login validation script
> >> ' © Matt Millross
> >> ' www.designplace.org
> >> ' free for use as long as copyright notice left intact
> >> ' For more scripts, visit www.designplace.org
> >> ' /////////////////////////////////////
> >>
> >> ' variables
> >> dim cnStr, rcSet, frmUID, frmPWD, sqlStr
> >>
> >> 'store form input into variables
> >> frmUID = Request.Form("UID")
> >> frmPWD = Request.Form("PWD")
> >>
> >> 'create connection and recordset objects
> >> Set cnStr = Server.CreateObject("ADODB.Connection")
> >> '// THIS IS NOT NEEDED!
> >> '// Set rcSet = Server.CreateObject("ADODB.Recordset")
> >>
> >> ' defining database connection (connectionstring.asp)
> >> cnStr.ConnectionString = path
> >> cnStr.Provider = provider
> >> cnStr.open
> >>
> >> ' execute sql and open as recordset
> >> '// sqlStr = "Select * From tblusers where username = '" _
> >> '// & Request.Form("UID") & "' and password = '" &
Request.Form("PWD")
> >> &
> >> "'"
> >> '// You've already stored the user/pass into a local var - use them!
> >> '// and NEVER use "Select * ..."
> >> '//
> >> '// http://aspfaq.com/show.asp?id 96
> >>
> >> sqlStr = "Select * From tblusers where UID = '" _
> >> & Request.Form("UID") & "' and PWD = '" & Request.Form("PWD") &
"'"
> >>
> >> ' Opens the returned values from the SQL as a recordset,
> >> ' ready for iteration by ASP
> >> '// <<< LINE 53 >>> set rcSet = cnStr.Execute(sqlStr)
> >> ' validate variables against database
> >> // If (not rcSet.BOF) and (not rcSet.EOF) then
> >>
> >> '// Check before processing
> >> If Len(frmUsername) < 1 Then frmUsername = "NULL"
> >> If Len(frmPassword) < 1 Then frmPassword = "NULL"
> >> '// Then go...
> >> Set rcSet = cnStr.Execute(sqlStr)
> >>
> >> If NOT rcSet.EOF Then
> >> response.cookies("validated_user") = frmUID
> >> response.write "<h1>Login successful!</h1>"
> >> '// Forget using rcSet.Fields, and just use rcSet
> >> '// directly
> >> response.write "<p>Welcome " & rcSet(1) & "</p>"
> >> else
> >> response.write "incorrect Username and/or Password"
> >> end if
> >>
> >> '// Don't forget to cleanup after yourself
> >> cnStr.Close: Set cnStr = Nothing
> >> Set rcSet = Nothing
> >> %>
> >>
> >>
> >> Regards
> >> Malcolm
> >>
> >>
> >> "malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
> >> news:4441273b$0$23177$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
> >> > UID and PWD are the 2 fields in my database that hold the
information.
> >> >
> >> > I have now changed the code
> >> >
> >> > "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
> >> > news:1145119070.271743.314040 [at] z34g2000cwc.googlegroups.com.. .
> >> >>
> >> >> malcolm wrote:
> >> >>> Hi, while trying to validate username and password on login form I
am
> >> >>> presented with the following error message
> >> >>>
> >> >>>
> >> >>> Microsoft JET Database Engine error '80040e10'
> >> >>>
> >> >>> No value given for one or more required parameters.
> >> >>>
> >> >>> /vdateUsr.asp, line 53
> >> >>>
> >> >>> The 2 fields within the database are text fields (UID) and (PWD)
> >> >>> these
> >> >>> are
> >> >>> spelt correctly!
> >> >>>
> >> >>
> >> >> <snip>
> >> >>> sqlStr = "Select * From tblusers where username = '" _
> >> >>> & Request.Form("UID") & "' and password = '" &
Request.Form("PWD")
> > &
> >> >>> "'"
> >> >>>
> >> >>
> >> >> No - they're not spelt correctly. In your SQL statement you refer
to
> >> >> two fields called username and password, yet you said they are
called
> >> >> UID and PWD. Which is correct?
> >> >>
> >> >> --
> >> >> Mike Brind
> >> >>
> >> >
> >> >
> >>
> >>
> >
> >
>
>
Re: Validate logins with ASP, MS Access and Cookies error
Name is the name of the field and the database is MS access.
"Mike Brind" <paxtonend [at] hotmail.com> wrote in message
news:1145125091.697554.101780 [at] v46g2000cwv.googlegroups.com.. .
Which field in the database holds the user's first name? And what type
of database are you using?
--
Mike Brind
malcolm wrote:
> Thanks Guys, i have now cleaned up the code and it is working ok. Just one
> thing I want to ask! on the login successful page it shows the username
> aas
> typed into the form UID field.. what I would like to do now is actully
> return another column from the database that stores the users 1st name :-)
>
> any tips
>
> here is the code I am using now. :-)
>
> <% [at] Language="VBScript"%>
>
> <!-- METADATA TYPE="typelib" FILE="C:\Program Files\Common
> Files\System\ado\msado15.dll" -->
> <!-- #include file="Connectionstring.asp" -->
> <%
>
> ' variables
> dim cnStr, rcSet, frmUID, frmPWD, sqlStr
>
> 'store form input into variables
> frmUID = Request.Form("UID")
> frmPWD = Request.Form("PWD")
>
> 'create connection and recordset objects
> Set cnStr = Server.CreateObject("ADODB.Connection")
>
> ' defining database connection (connectionstring.asp)
> cnStr.ConnectionString = path
> cnStr.Provider = provider
> cnStr.open
>
> ' execute sql and open as recordset
>
> sqlStr = "Select * From tblusers where UID = '" _
> & Request.Form("UID") & "' and PWD = '" & Request.Form("PWD") & "'"
>
> ' Opens the returned values from the SQL as a recordset,
> ' ready for iteration by ASP
> ' validate variables against database
> // If (not rcSet.BOF) and (not rcSet.EOF) then
>
> If Len(frmUID) < 1 Then frmUID = "NULL"
> If Len(frmPWD) < 1 Then frmPWD = "NULL"
>
> Set rcSet = cnStr.Execute(sqlStr)
>
> If NOT rcSet.EOF Then
> response.cookies("validated_user") = frmUID
> response.write "<h1>Login successful!</h1>"
>
> response.write "<p>Welcome " & rcSet(0) & "</p>"
> else
> response.write "Incorrect Username and/or Password"
> end if
>
> cnStr.Close: Set cnStr = Nothing
> Set rcSet = Nothing
> %>
>
> I had to change this code
> response.write "<p>Welcome " & rcSet(1) & "</p>"
> to this code
> response.write "<p>Welcome " & rcSet(0) & "</p>"
> so that it would display the username and not the password ;-)
> not bad for a guess. :-)
>
> Regards
> Malcolm
>
>
> "Steven Burn" <somewhere [at] in-time.invalid> wrote in message
> news:e%237BQOLYGHA.3448 [at] TK2MSFTNGP04.phx.gbl...
> > Change;
> >
> > sqlStr = "Select * From tblusers where UID = '" _
> > & Request.Form("UID") & "' and PWD = '" & Request.Form("PWD") & "'"
> >
> > ' Opens the returned values from the SQL as a recordset,
> > ' ready for iteration by ASP
> > '// <<< LINE 53 >>> set rcSet = cnStr.Execute(sqlStr)
> > ' validate variables against database
> > // If (not rcSet.BOF) and (not rcSet.EOF) then
> >
> > '// Check before processing
> > If Len(frmUsername) < 1 Then frmUsername = "NULL"
> > If Len(frmPassword) < 1 Then frmPassword = "NULL"
> >
> > To;
> >
> > '// Check before processing
> > If Len(frmUsername) < 1 Then frmUsername = "NULL"
> > If Len(frmPassword) < 1 Then frmPassword = "NULL"
> > Response.Write "<b><i>DEBUG</i><b><br>Username: " _
> > & frmUID & "<br>Password: " & frmPWD
> > sqlStr = "Select * From tblusers where UID = '" _
> > & frmUID & "' and PWD = '" & frmPWD & "'"
> >
> > ' Opens the returned values from the SQL as a recordset,
> > ' ready for iteration by ASP
> > '// <<< LINE 53 >>> set rcSet = cnStr.Execute(sqlStr)
> > ' validate variables against database
> > // If (not rcSet.BOF) and (not rcSet.EOF) then
> >
> > --
> > Regards
> >
> > Steven Burn
> > Ur I.T. Mate Group
> > www.it-mate.co.uk
> >
> > Keeping it FREE!
> >
> > "malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
> > news:4441284e$0$23185$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
> >> I am now presented with incorrect Username and/or Password. I have
> >> double
> >> checked this.
> >>
> >> I now have the following code in my page
> >>
> >> <% [at] Language="VBScript"%>
> >>
> >> <!-- METADATA TYPE="typelib" FILE="C:\Program Files\Common
> >> Files\System\ado\msado15.dll" -->
> >> <!-- #include file="Connectionstring.asp" -->
> >> <%
> >> ' /////////////////////////////////////
> >> ' login validation script
> >> ' © Matt Millross
> >> ' www.designplace.org
> >> ' free for use as long as copyright notice left intact
> >> ' For more scripts, visit www.designplace.org
> >> ' /////////////////////////////////////
> >>
> >> ' variables
> >> dim cnStr, rcSet, frmUID, frmPWD, sqlStr
> >>
> >> 'store form input into variables
> >> frmUID = Request.Form("UID")
> >> frmPWD = Request.Form("PWD")
> >>
> >> 'create connection and recordset objects
> >> Set cnStr = Server.CreateObject("ADODB.Connection")
> >> '// THIS IS NOT NEEDED!
> >> '// Set rcSet = Server.CreateObject("ADODB.Recordset")
> >>
> >> ' defining database connection (connectionstring.asp)
> >> cnStr.ConnectionString = path
> >> cnStr.Provider = provider
> >> cnStr.open
> >>
> >> ' execute sql and open as recordset
> >> '// sqlStr = "Select * From tblusers where username = '" _
> >> '// & Request.Form("UID") & "' and password = '" &
> >> Request.Form("PWD")
> >> &
> >> "'"
> >> '// You've already stored the user/pass into a local var - use them!
> >> '// and NEVER use "Select * ..."
> >> '//
> >> '// http://aspfaq.com/show.asp?id 96
> >>
> >> sqlStr = "Select * From tblusers where UID = '" _
> >> & Request.Form("UID") & "' and PWD = '" & Request.Form("PWD") &
> >> "'"
> >>
> >> ' Opens the returned values from the SQL as a recordset,
> >> ' ready for iteration by ASP
> >> '// <<< LINE 53 >>> set rcSet = cnStr.Execute(sqlStr)
> >> ' validate variables against database
> >> // If (not rcSet.BOF) and (not rcSet.EOF) then
> >>
> >> '// Check before processing
> >> If Len(frmUsername) < 1 Then frmUsername = "NULL"
> >> If Len(frmPassword) < 1 Then frmPassword = "NULL"
> >> '// Then go...
> >> Set rcSet = cnStr.Execute(sqlStr)
> >>
> >> If NOT rcSet.EOF Then
> >> response.cookies("validated_user") = frmUID
> >> response.write "<h1>Login successful!</h1>"
> >> '// Forget using rcSet.Fields, and just use rcSet
> >> '// directly
> >> response.write "<p>Welcome " & rcSet(1) & "</p>"
> >> else
> >> response.write "incorrect Username and/or Password"
> >> end if
> >>
> >> '// Don't forget to cleanup after yourself
> >> cnStr.Close: Set cnStr = Nothing
> >> Set rcSet = Nothing
> >> %>
> >>
> >>
> >> Regards
> >> Malcolm
> >>
> >>
> >> "malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
> >> news:4441273b$0$23177$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
> >> > UID and PWD are the 2 fields in my database that hold the
> >> > information.
> >> >
> >> > I have now changed the code
> >> >
> >> > "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
> >> > news:1145119070.271743.314040 [at] z34g2000cwc.googlegroups.com.. .
> >> >>
> >> >> malcolm wrote:
> >> >>> Hi, while trying to validate username and password on login form I
> >> >>> am
> >> >>> presented with the following error message
> >> >>>
> >> >>>
> >> >>> Microsoft JET Database Engine error '80040e10'
> >> >>>
> >> >>> No value given for one or more required parameters.
> >> >>>
> >> >>> /vdateUsr.asp, line 53
> >> >>>
> >> >>> The 2 fields within the database are text fields (UID) and (PWD)
> >> >>> these
> >> >>> are
> >> >>> spelt correctly!
> >> >>>
> >> >>
> >> >> <snip>
> >> >>> sqlStr = "Select * From tblusers where username = '" _
> >> >>> & Request.Form("UID") & "' and password = '" &
> >> >>> Request.Form("PWD")
> > &
> >> >>> "'"
> >> >>>
> >> >>
> >> >> No - they're not spelt correctly. In your SQL statement you refer
> >> >> to
> >> >> two fields called username and password, yet you said they are
> >> >> called
> >> >> UID and PWD. Which is correct?
> >> >>
> >> >> --
> >> >> Mike Brind
> >> >>
> >> >
> >> >
> >>
> >>
> >
> >
Re: Validate logins with ASP, MS Access and Cookies error
Bad choice of field name. "Name" a reserved word in Access. Steve
Burns posted the correct answer to your question, but it would have
thrown up an error in this case.
Change it if you can, but if not, your sqlStr will have to look like
this:
"Select [name], UID From tblusers where UID =3D '"
_ & Request.Form("UID") & "' and PWD =3D '" & Request.Form("PWD") & "'"
Even then, there are other problems with the approach you are taking.
If you copy and paste the following line into the user name and
password fields in your form:
' or ''=3D'
You will always log in successfully. This is a common SQL Injection
attack method. Also, if you have someone who's username contains an
apostophe, you will get errors. The best defence against this is to
use a saved parameter query in your Access database:
http://www.xefteri.com/articles/show.cfm?id=3D6
--
Mike Brind
malcolm wrote:
> Name is the name of the field and the database is MS access.
>
>
>
> "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
> news:1145125091.697554.101780 [at] v46g2000cwv.googlegroups.com.. .
> Which field in the database holds the user's first name? And what type
> of database are you using?
>
> --
> Mike Brind
>
>
> malcolm wrote:
> > Thanks Guys, i have now cleaned up the code and it is working ok. Just =
one
> > thing I want to ask! on the login successful page it shows the username
> > aas
> > typed into the form UID field.. what I would like to do now is actully
> > return another column from the database that stores the users 1st name =
:-)
> >
> > any tips
> >
> > here is the code I am using now. :-)
> >
> > <% [at] Language=3D"VBScript"%>
> >
> > <!-- METADATA TYPE=3D"typelib" FILE=3D"C:\Program Files\Common
> > Files\System\ado\msado15.dll" -->
> > <!-- #include file=3D"Connectionstring.asp" -->
> > <%
> >
> > ' variables
> > dim cnStr, rcSet, frmUID, frmPWD, sqlStr
> >
> > 'store form input into variables
> > frmUID =3D Request.Form("UID")
> > frmPWD =3D Request.Form("PWD")
> >
> > 'create connection and recordset objects
> > Set cnStr =3D Server.CreateObject("ADODB.Connection")
> >
> > ' defining database connection (connectionstring.asp)
> > cnStr.ConnectionString =3D path
> > cnStr.Provider =3D provider
> > cnStr.open
> >
> > ' execute sql and open as recordset
> >
> > sqlStr =3D "Select * From tblusers where UID =3D '" _
> > & Request.Form("UID") & "' and PWD =3D '" & Request.Form("PWD") & =
"'"
> >
> > ' Opens the returned values from the SQL as a recordset,
> > ' ready for iteration by ASP
> > ' validate variables against database
> > // If (not rcSet.BOF) and (not rcSet.EOF) then
> >
> > If Len(frmUID) < 1 Then frmUID =3D "NULL"
> > If Len(frmPWD) < 1 Then frmPWD =3D "NULL"
> >
> > Set rcSet =3D cnStr.Execute(sqlStr)
> >
> > If NOT rcSet.EOF Then
> > response.cookies("validated_user") =3D frmUID
> > response.write "<h1>Login successful!</h1>"
> >
> > response.write "<p>Welcome " & rcSet(0) & "</p>"
> > else
> > response.write "Incorrect Username and/or Password"
> > end if
> >
> > cnStr.Close: Set cnStr =3D Nothing
> > Set rcSet =3D Nothing
> > %>
> >
> > I had to change this code
> > response.write "<p>Welcome " & rcSet(1) & "</p>"
> > to this code
> > response.write "<p>Welcome " & rcSet(0) & "</p>"
> > so that it would display the username and not the password ;-)
> > not bad for a guess. :-)
> >
> > Regards
> > Malcolm
> >
> >
> > "Steven Burn" <somewhere [at] in-time.invalid> wrote in message
> > news:e%237BQOLYGHA.3448 [at] TK2MSFTNGP04.phx.gbl...
> > > Change;
> > >
> > > sqlStr =3D "Select * From tblusers where UID =3D '" _
> > > & Request.Form("UID") & "' and PWD =3D '" & Request.Form("PWD") &=
"'"
> > >
> > > ' Opens the returned values from the SQL as a recordset,
> > > ' ready for iteration by ASP
> > > '// <<< LINE 53 >>> set rcSet =3D cnStr.Execute(sqlStr)
> > > ' validate variables against database
> > > // If (not rcSet.BOF) and (not rcSet.EOF) then
> > >
> > > '// Check before processing
> > > If Len(frmUsername) < 1 Then frmUsername =3D "NULL"
> > > If Len(frmPassword) < 1 Then frmPassword =3D "NULL"
> > >
> > > To;
> > >
> > > '// Check before processing
> > > If Len(frmUsername) < 1 Then frmUsername =3D "NULL"
> > > If Len(frmPassword) < 1 Then frmPassword =3D "NULL"
> > > Response.Write "<b><i>DEBUG</i><b><br>Username: " _
> > > & frmUID & "<br>Password: " & frmPWD
> > > sqlStr =3D "Select * From tblusers where UID =3D '" _
> > > & frmUID & "' and PWD =3D '" & frmPWD & "'"
> > >
> > > ' Opens the returned values from the SQL as a recordset,
> > > ' ready for iteration by ASP
> > > '// <<< LINE 53 >>> set rcSet =3D cnStr.Execute(sqlStr)
> > > ' validate variables against database
> > > // If (not rcSet.BOF) and (not rcSet.EOF) then
> > >
> > > --
> > > Regards
> > >
> > > Steven Burn
> > > Ur I.T. Mate Group
> > > www.it-mate.co.uk
> > >
> > > Keeping it FREE!
> > >
> > > "malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
> > > news:4441284e$0$23185$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
> > >> I am now presented with incorrect Username and/or Password. I have
> > >> double
> > >> checked this.
> > >>
> > >> I now have the following code in my page
> > >>
> > >> <% [at] Language=3D"VBScript"%>
> > >>
> > >> <!-- METADATA TYPE=3D"typelib" FILE=3D"C:\Program Files\Common
> > >> Files\System\ado\msado15.dll" -->
> > >> <!-- #include file=3D"Connectionstring.asp" -->
> > >> <%
> > >> ' /////////////////////////////////////
> > >> ' login validation script
> > >> ' =A9 Matt Millross
> > >> ' www.designplace.org
> > >> ' free for use as long as copyright notice left intact
> > >> ' For more scripts, visit www.designplace.org
> > >> ' /////////////////////////////////////
> > >>
> > >> ' variables
> > >> dim cnStr, rcSet, frmUID, frmPWD, sqlStr
> > >>
> > >> 'store form input into variables
> > >> frmUID =3D Request.Form("UID")
> > >> frmPWD =3D Request.Form("PWD")
> > >>
> > >> 'create connection and recordset objects
> > >> Set cnStr =3D Server.CreateObject("ADODB.Connection")
> > >> '// THIS IS NOT NEEDED!
> > >> '// Set rcSet =3D Server.CreateObject("ADODB.Recordset")
> > >>
> > >> ' defining database connection (connectionstring.asp)
> > >> cnStr.ConnectionString =3D path
> > >> cnStr.Provider =3D provider
> > >> cnStr.open
> > >>
> > >> ' execute sql and open as recordset
> > >> '// sqlStr =3D "Select * From tblusers where username =3D '" _
> > >> '// & Request.Form("UID") & "' and password =3D '" &
> > >> Request.Form("PWD")
> > >> &
> > >> "'"
> > >> '// You've already stored the user/pass into a local var - use them!
> > >> '// and NEVER use "Select * ..."
> > >> '//
> > >> '// http://aspfaq.com/show.asp?id=3D2096
> > >>
> > >> sqlStr =3D "Select * From tblusers where UID =3D '" _
> > >> & Request.Form("UID") & "' and PWD =3D '" & Request.Form("PWD")=
&
> > >> "'"
> > >>
> > >> ' Opens the returned values from the SQL as a recordset,
> > >> ' ready for iteration by ASP
> > >> '// <<< LINE 53 >>> set rcSet =3D cnStr.Execute(sqlStr)
> > >> ' validate variables against database
> > >> // If (not rcSet.BOF) and (not rcSet.EOF) then
> > >>
> > >> '// Check before processing
> > >> If Len(frmUsername) < 1 Then frmUsername =3D "NULL"
> > >> If Len(frmPassword) < 1 Then frmPassword =3D "NULL"
> > >> '// Then go...
> > >> Set rcSet =3D cnStr.Execute(sqlStr)
> > >>
> > >> If NOT rcSet.EOF Then
> > >> response.cookies("validated_user") =3D frmUID
> > >> response.write "<h1>Login successful!</h1>"
> > >> '// Forget using rcSet.Fields, and just use rcSet
> > >> '// directly
> > >> response.write "<p>Welcome " & rcSet(1) & "</p>"
> > >> else
> > >> response.write "incorrect Username and/or Password"
> > >> end if
> > >>
> > >> '// Don't forget to cleanup after yourself
> > >> cnStr.Close: Set cnStr =3D Nothing
> > >> Set rcSet =3D Nothing
> > >> %>
> > >>
> > >>
> > >> Regards
> > >> Malcolm
> > >>
> > >>
> > >> "malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
> > >> news:4441273b$0$23177$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
> > >> > UID and PWD are the 2 fields in my database that hold the
> > >> > information.
> > >> >
> > >> > I have now changed the code
> > >> >
> > >> > "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
> > >> > news:1145119070.271743.314040 [at] z34g2000cwc.googlegroups.com.. .
> > >> >>
> > >> >> malcolm wrote:
> > >> >>> Hi, while trying to validate username and password on login form=
I
> > >> >>> am
> > >> >>> presented with the following error message
> > >> >>>
> > >> >>>
> > >> >>> Microsoft JET Database Engine error '80040e10'
> > >> >>>
> > >> >>> No value given for one or more required parameters.
> > >> >>>
> > >> >>> /vdateUsr.asp, line 53
> > >> >>>
> > >> >>> The 2 fields within the database are text fields (UID) and (PWD)
> > >> >>> these
> > >> >>> are
> > >> >>> spelt correctly!
> > >> >>>
> > >> >>
> > >> >> <snip>
> > >> >>> sqlStr =3D "Select * From tblusers where username =3D '" _
> > >> >>> & Request.Form("UID") & "' and password =3D '" &
> > >> >>> Request.Form("PWD")
> > > &
> > >> >>> "'"
> > >> >>>
> > >> >>
> > >> >> No - they're not spelt correctly. In your SQL statement you ref=
er
> > >> >> to
> > >> >> two fields called username and password, yet you said they are
> > >> >> called
> > >> >> UID and PWD. Which is correct?
> > >> >>
> > >> >> --
> > >> >> Mike Brind
> > >> >>
> > >> >
> > >> >
> > >>
> > >>
> > >
> > >
Re: Validate logins with ASP, MS Access and Cookies error
I have now changed the code which Mike advised and it now works.
I have no idea how to do that Steven! I did read the article that you refer
me too.
I have not stopped using "Select" because I don't know what to replace it
with!! I have gone back over the trail and found this
'// and NEVER use "Select * ..."
'//
'// http://aspfaq.com/show.asp?id 96
I read that article. 2096 1st time but not sure how to implement the changes
you recommend ?
Regards
Malcolm
"Steven Burn" <somewhere [at] in-time.invalid> wrote in message
news:edTpQvLYGHA.4484 [at] TK2MSFTNGP02.phx.gbl...
> AGAIN, stop using "Select *" !!!!!!
>
> http://aspfaq.com/show.asp?id 96
>
> As for returning the users actual name, just select it from the DB;
>
> strSQL = "Select UsersName, UID From tblUsers Where UID = '" & strUID &
> "'"
>
> Where "UsersName" is the name of the field that holds the data you
> require.
>
> --
> Regards
>
> Steven Burn
> Ur I.T. Mate Group
> www.it-mate.co.uk
>
> Keeping it FREE!
>
> "malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
> news:444133fc$0$23199$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
>> Thanks Guys, i have now cleaned up the code and it is working ok. Just
>> one
>> thing I want to ask! on the login successful page it shows the username
> aas
>> typed into the form UID field.. what I would like to do now is actully
>> return another column from the database that stores the users 1st name
>> :-)
>>
>> any tips
>>
>> here is the code I am using now. :-)
>>
>> <% [at] Language="VBScript"%>
>>
>> <!-- METADATA TYPE="typelib" FILE="C:\Program Files\Common
>> Files\System\ado\msado15.dll" -->
>> <!-- #include file="Connectionstring.asp" -->
>> <%
>>
>> ' variables
>> dim cnStr, rcSet, frmUID, frmPWD, sqlStr
>>
>> 'store form input into variables
>> frmUID = Request.Form("UID")
>> frmPWD = Request.Form("PWD")
>>
>> 'create connection and recordset objects
>> Set cnStr = Server.CreateObject("ADODB.Connection")
>>
>> ' defining database connection (connectionstring.asp)
>> cnStr.ConnectionString = path
>> cnStr.Provider = provider
>> cnStr.open
>>
>> ' execute sql and open as recordset
>>
>> sqlStr = "Select * From tblusers where UID = '" _
>> & Request.Form("UID") & "' and PWD = '" & Request.Form("PWD") & "'"
>>
>> ' Opens the returned values from the SQL as a recordset,
>> ' ready for iteration by ASP
>> ' validate variables against database
>> // If (not rcSet.BOF) and (not rcSet.EOF) then
>>
>> If Len(frmUID) < 1 Then frmUID = "NULL"
>> If Len(frmPWD) < 1 Then frmPWD = "NULL"
>>
>> Set rcSet = cnStr.Execute(sqlStr)
>>
>> If NOT rcSet.EOF Then
>> response.cookies("validated_user") = frmUID
>> response.write "<h1>Login successful!</h1>"
>>
>> response.write "<p>Welcome " & rcSet(0) & "</p>"
>> else
>> response.write "Incorrect Username and/or Password"
>> end if
>>
>> cnStr.Close: Set cnStr = Nothing
>> Set rcSet = Nothing
>> %>
>>
>> I had to change this code
>> response.write "<p>Welcome " & rcSet(1) & "</p>"
>> to this code
>> response.write "<p>Welcome " & rcSet(0) & "</p>"
>> so that it would display the username and not the password ;-)
>> not bad for a guess. :-)
>>
>> Regards
>> Malcolm
>>
>>
>> "Steven Burn" <somewhere [at] in-time.invalid> wrote in message
>> news:e%237BQOLYGHA.3448 [at] TK2MSFTNGP04.phx.gbl...
>> > Change;
>> >
>> > sqlStr = "Select * From tblusers where UID = '" _
>> > & Request.Form("UID") & "' and PWD = '" & Request.Form("PWD") & "'"
>> >
>> > ' Opens the returned values from the SQL as a recordset,
>> > ' ready for iteration by ASP
>> > '// <<< LINE 53 >>> set rcSet = cnStr.Execute(sqlStr)
>> > ' validate variables against database
>> > // If (not rcSet.BOF) and (not rcSet.EOF) then
>> >
>> > '// Check before processing
>> > If Len(frmUsername) < 1 Then frmUsername = "NULL"
>> > If Len(frmPassword) < 1 Then frmPassword = "NULL"
>> >
>> > To;
>> >
>> > '// Check before processing
>> > If Len(frmUsername) < 1 Then frmUsername = "NULL"
>> > If Len(frmPassword) < 1 Then frmPassword = "NULL"
>> > Response.Write "<b><i>DEBUG</i><b><br>Username: " _
>> > & frmUID & "<br>Password: " & frmPWD
>> > sqlStr = "Select * From tblusers where UID = '" _
>> > & frmUID & "' and PWD = '" & frmPWD & "'"
>> >
>> > ' Opens the returned values from the SQL as a recordset,
>> > ' ready for iteration by ASP
>> > '// <<< LINE 53 >>> set rcSet = cnStr.Execute(sqlStr)
>> > ' validate variables against database
>> > // If (not rcSet.BOF) and (not rcSet.EOF) then
>> >
>> > --
>> > Regards
>> >
>> > Steven Burn
>> > Ur I.T. Mate Group
>> > www.it-mate.co.uk
>> >
>> > Keeping it FREE!
>> >
>> > "malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
>> > news:4441284e$0$23185$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
>> >> I am now presented with incorrect Username and/or Password. I have
> double
>> >> checked this.
>> >>
>> >> I now have the following code in my page
>> >>
>> >> <% [at] Language="VBScript"%>
>> >>
>> >> <!-- METADATA TYPE="typelib" FILE="C:\Program Files\Common
>> >> Files\System\ado\msado15.dll" -->
>> >> <!-- #include file="Connectionstring.asp" -->
>> >> <%
>> >> ' /////////////////////////////////////
>> >> ' login validation script
>> >> ' © Matt Millross
>> >> ' www.designplace.org
>> >> ' free for use as long as copyright notice left intact
>> >> ' For more scripts, visit www.designplace.org
>> >> ' /////////////////////////////////////
>> >>
>> >> ' variables
>> >> dim cnStr, rcSet, frmUID, frmPWD, sqlStr
>> >>
>> >> 'store form input into variables
>> >> frmUID = Request.Form("UID")
>> >> frmPWD = Request.Form("PWD")
>> >>
>> >> 'create connection and recordset objects
>> >> Set cnStr = Server.CreateObject("ADODB.Connection")
>> >> '// THIS IS NOT NEEDED!
>> >> '// Set rcSet = Server.CreateObject("ADODB.Recordset")
>> >>
>> >> ' defining database connection (connectionstring.asp)
>> >> cnStr.ConnectionString = path
>> >> cnStr.Provider = provider
>> >> cnStr.open
>> >>
>> >> ' execute sql and open as recordset
>> >> '// sqlStr = "Select * From tblusers where username = '" _
>> >> '// & Request.Form("UID") & "' and password = '" &
> Request.Form("PWD")
>> >> &
>> >> "'"
>> >> '// You've already stored the user/pass into a local var - use them!
>> >> '// and NEVER use "Select * ..."
>> >> '//
>> >> '// http://aspfaq.com/show.asp?id 96
>> >>
>> >> sqlStr = "Select * From tblusers where UID = '" _
>> >> & Request.Form("UID") & "' and PWD = '" & Request.Form("PWD") &
> "'"
>> >>
>> >> ' Opens the returned values from the SQL as a recordset,
>> >> ' ready for iteration by ASP
>> >> '// <<< LINE 53 >>> set rcSet = cnStr.Execute(sqlStr)
>> >> ' validate variables against database
>> >> // If (not rcSet.BOF) and (not rcSet.EOF) then
>> >>
>> >> '// Check before processing
>> >> If Len(frmUsername) < 1 Then frmUsername = "NULL"
>> >> If Len(frmPassword) < 1 Then frmPassword = "NULL"
>> >> '// Then go...
>> >> Set rcSet = cnStr.Execute(sqlStr)
>> >>
>> >> If NOT rcSet.EOF Then
>> >> response.cookies("validated_user") = frmUID
>> >> response.write "<h1>Login successful!</h1>"
>> >> '// Forget using rcSet.Fields, and just use rcSet
>> >> '// directly
>> >> response.write "<p>Welcome " & rcSet(1) & "</p>"
>> >> else
>> >> response.write "incorrect Username and/or Password"
>> >> end if
>> >>
>> >> '// Don't forget to cleanup after yourself
>> >> cnStr.Close: Set cnStr = Nothing
>> >> Set rcSet = Nothing
>> >> %>
>> >>
>> >>
>> >> Regards
>> >> Malcolm
>> >>
>> >>
>> >> "malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
>> >> news:4441273b$0$23177$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
>> >> > UID and PWD are the 2 fields in my database that hold the
> information.
>> >> >
>> >> > I have now changed the code
>> >> >
>> >> > "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
>> >> > news:1145119070.271743.314040 [at] z34g2000cwc.googlegroups.com.. .
>> >> >>
>> >> >> malcolm wrote:
>> >> >>> Hi, while trying to validate username and password on login form I
> am
>> >> >>> presented with the following error message
>> >> >>>
>> >> >>>
>> >> >>> Microsoft JET Database Engine error '80040e10'
>> >> >>>
>> >> >>> No value given for one or more required parameters.
>> >> >>>
>> >> >>> /vdateUsr.asp, line 53
>> >> >>>
>> >> >>> The 2 fields within the database are text fields (UID) and (PWD)
>> >> >>> these
>> >> >>> are
>> >> >>> spelt correctly!
>> >> >>>
>> >> >>
>> >> >> <snip>
>> >> >>> sqlStr = "Select * From tblusers where username = '" _
>> >> >>> & Request.Form("UID") & "' and password = '" &
> Request.Form("PWD")
>> > &
>> >> >>> "'"
>> >> >>>
>> >> >>
>> >> >> No - they're not spelt correctly. In your SQL statement you refer
> to
>> >> >> two fields called username and password, yet you said they are
> called
>> >> >> UID and PWD. Which is correct?
>> >> >>
>> >> >> --
>> >> >> Mike Brind
>> >> >>
>> >> >
>> >> >
>> >>
>> >>
>> >
>> >
>>
>>
>
>
Re: Validate logins with ASP, MS Access and Cookies error
Steve was pointing out that SELECT *(asterisk) is a BAD thing. SELECT
* returns all the rows in the tables in your FROM clause. When we
changed the SELECT statement to SELECT [name], UID FROM... it got round
the SELECT * problem.
If you plan to do much more ASP, I would advise looking for tutorials
that explain the code they offer, rather than these kinds of free
scripts. There are some excellent sites around, including
www.asp101.com and www.learnasp.com.
Another way to learn stuff is to make mistakes, and copy and paste the
error messages into www.aspfaq.com.
Good luck
--
Mike Brind
malcolm wrote:
> I have now changed the code which Mike advised and it now works.
>
> I have no idea how to do that Steven! I did read the article that you ref=
er
> me too.
>
> I have not stopped using "Select" because I don't know what to replace it
> with!! I have gone back over the trail and found this
>
> '// and NEVER use "Select * ..."
>
> '//
>
> '// http://aspfaq.com/show.asp?id=3D2096
>
>
>
> I read that article. 2096 1st time but not sure how to implement the chan=
ges
> you recommend ?
>
>
>
>
>
> Regards
>
> Malcolm
>
>
>
>
>
> "Steven Burn" <somewhere [at] in-time.invalid> wrote in message
> news:edTpQvLYGHA.4484 [at] TK2MSFTNGP02.phx.gbl...
> > AGAIN, stop using "Select *" !!!!!!
> >
> > http://aspfaq.com/show.asp?id=3D2096
> >
> > As for returning the users actual name, just select it from the DB;
> >
> > strSQL =3D "Select UsersName, UID From tblUsers Where UID =3D '" & strU=
ID &
> > "'"
> >
> > Where "UsersName" is the name of the field that holds the data you
> > require.
> >
> > --
> > Regards
> >
> > Steven Burn
> > Ur I.T. Mate Group
> > www.it-mate.co.uk
> >
> > Keeping it FREE!
> >
> > "malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
> > news:444133fc$0$23199$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
> >> Thanks Guys, i have now cleaned up the code and it is working ok. Just
> >> one
> >> thing I want to ask! on the login successful page it shows the username
> > aas
> >> typed into the form UID field.. what I would like to do now is actully
> >> return another column from the database that stores the users 1st name
> >> :-)
> >>
> >> any tips
> >>
> >> here is the code I am using now. :-)
> >>
> >> <% [at] Language=3D"VBScript"%>
> >>
> >> <!-- METADATA TYPE=3D"typelib" FILE=3D"C:\Program Files\Common
> >> Files\System\ado\msado15.dll" -->
> >> <!-- #include file=3D"Connectionstring.asp" -->
> >> <%
> >>
> >> ' variables
> >> dim cnStr, rcSet, frmUID, frmPWD, sqlStr
> >>
> >> 'store form input into variables
> >> frmUID =3D Request.Form("UID")
> >> frmPWD =3D Request.Form("PWD")
> >>
> >> 'create connection and recordset objects
> >> Set cnStr =3D Server.CreateObject("ADODB.Connection")
> >>
> >> ' defining database connection (connectionstring.asp)
> >> cnStr.ConnectionString =3D path
> >> cnStr.Provider =3D provider
> >> cnStr.open
> >>
> >> ' execute sql and open as recordset
> >>
> >> sqlStr =3D "Select * From tblusers where UID =3D '" _
> >> & Request.Form("UID") & "' and PWD =3D '" & Request.Form("PWD") &=
"'"
> >>
> >> ' Opens the returned values from the SQL as a recordset,
> >> ' ready for iteration by ASP
> >> ' validate variables against database
> >> // If (not rcSet.BOF) and (not rcSet.EOF) then
> >>
> >> If Len(frmUID) < 1 Then frmUID =3D "NULL"
> >> If Len(frmPWD) < 1 Then frmPWD =3D "NULL"
> >>
> >> Set rcSet =3D cnStr.Execute(sqlStr)
> >>
> >> If NOT rcSet.EOF Then
> >> response.cookies("validated_user") =3D frmUID
> >> response.write "<h1>Login successful!</h1>"
> >>
> >> response.write "<p>Welcome " & rcSet(0) & "</p>"
> >> else
> >> response.write "Incorrect Username and/or Password"
> >> end if
> >>
> >> cnStr.Close: Set cnStr =3D Nothing
> >> Set rcSet =3D Nothing
> >> %>
> >>
> >> I had to change this code
> >> response.write "<p>Welcome " & rcSet(1) & "</p>"
> >> to this code
> >> response.write "<p>Welcome " & rcSet(0) & "</p>"
> >> so that it would display the username and not the password ;-)
> >> not bad for a guess. :-)
> >>
> >> Regards
> >> Malcolm
> >>
> >>
> >> "Steven Burn" <somewhere [at] in-time.invalid> wrote in message
> >> news:e%237BQOLYGHA.3448 [at] TK2MSFTNGP04.phx.gbl...
> >> > Change;
> >> >
> >> > sqlStr =3D "Select * From tblusers where UID =3D '" _
> >> > & Request.Form("UID") & "' and PWD =3D '" & Request.Form("PWD") =
& "'"
> >> >
> >> > ' Opens the returned values from the SQL as a recordset,
> >> > ' ready for iteration by ASP
> >> > '// <<< LINE 53 >>> set rcSet =3D cnStr.Execute(sqlStr)
> >> > ' validate variables against database
> >> > // If (not rcSet.BOF) and (not rcSet.EOF) then
> >> >
> >> > '// Check before processing
> >> > If Len(frmUsername) < 1 Then frmUsername =3D "NULL"
> >> > If Len(frmPassword) < 1 Then frmPassword =3D "NULL"
> >> >
> >> > To;
> >> >
> >> > '// Check before processing
> >> > If Len(frmUsername) < 1 Then frmUsername =3D "NULL"
> >> > If Len(frmPassword) < 1 Then frmPassword =3D "NULL"
> >> > Response.Write "<b><i>DEBUG</i><b><br>Username: " _
> >> > & frmUID & "<br>Password: " & frmPWD
> >> > sqlStr =3D "Select * From tblusers where UID =3D '" _
> >> > & frmUID & "' and PWD =3D '" & frmPWD & "'"
> >> >
> >> > ' Opens the returned values from the SQL as a recordset,
> >> > ' ready for iteration by ASP
> >> > '// <<< LINE 53 >>> set rcSet =3D cnStr.Execute(sqlStr)
> >> > ' validate variables against database
> >> > // If (not rcSet.BOF) and (not rcSet.EOF) then
> >> >
> >> > --
> >> > Regards
> >> >
> >> > Steven Burn
> >> > Ur I.T. Mate Group
> >> > www.it-mate.co.uk
> >> >
> >> > Keeping it FREE!
> >> >
> >> > "malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
> >> > news:4441284e$0$23185$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
> >> >> I am now presented with incorrect Username and/or Password. I have
> > double
> >> >> checked this.
> >> >>
> >> >> I now have the following code in my page
> >> >>
> >> >> <% [at] Language=3D"VBScript"%>
> >> >>
> >> >> <!-- METADATA TYPE=3D"typelib" FILE=3D"C:\Program Files\Common
> >> >> Files\System\ado\msado15.dll" -->
> >> >> <!-- #include file=3D"Connectionstring.asp" -->
> >> >> <%
> >> >> ' /////////////////////////////////////
> >> >> ' login validation script
> >> >> ' =A9 Matt Millross
> >> >> ' www.designplace.org
> >> >> ' free for use as long as copyright notice left intact
> >> >> ' For more scripts, visit www.designplace.org
> >> >> ' /////////////////////////////////////
> >> >>
> >> >> ' variables
> >> >> dim cnStr, rcSet, frmUID, frmPWD, sqlStr
> >> >>
> >> >> 'store form input into variables
> >> >> frmUID =3D Request.Form("UID")
> >> >> frmPWD =3D Request.Form("PWD")
> >> >>
> >> >> 'create connection and recordset objects
> >> >> Set cnStr =3D Server.CreateObject("ADODB.Connection")
> >> >> '// THIS IS NOT NEEDED!
> >> >> '// Set rcSet =3D Server.CreateObject("ADODB.Recordset")
> >> >>
> >> >> ' defining database connection (connectionstring.asp)
> >> >> cnStr.ConnectionString =3D path
> >> >> cnStr.Provider =3D provider
> >> >> cnStr.open
> >> >>
> >> >> ' execute sql and open as recordset
> >> >> '// sqlStr =3D "Select * From tblusers where username =3D '" _
> >> >> '// & Request.Form("UID") & "' and password =3D '" &
> > Request.Form("PWD")
> >> >> &
> >> >> "'"
> >> >> '// You've already stored the user/pass into a local var - use them!
> >> >> '// and NEVER use "Select * ..."
> >> >> '//
> >> >> '// http://aspfaq.com/show.asp?id=3D2096
> >> >>
> >> >> sqlStr =3D "Select * From tblusers where UID =3D '" _
> >> >> & Request.Form("UID") & "' and PWD =3D '" & Request.Form("PWD"=
) &
> > "'"
> >> >>
> >> >> ' Opens the returned values from the SQL as a recordset,
> >> >> ' ready for iteration by ASP
> >> >> '// <<< LINE 53 >>> set rcSet =3D cnStr.Execute(sqlStr)
> >> >> ' validate variables against database
> >> >> // If (not rcSet.BOF) and (not rcSet.EOF) then
> >> >>
> >> >> '// Check before processing
> >> >> If Len(frmUsername) < 1 Then frmUsername =3D "NULL"
> >> >> If Len(frmPassword) < 1 Then frmPassword =3D "NULL"
> >> >> '// Then go...
> >> >> Set rcSet =3D cnStr.Execute(sqlStr)
> >> >>
> >> >> If NOT rcSet.EOF Then
> >> >> response.cookies("validated_user") =3D frmUID
> >> >> response.write "<h1>Login successful!</h1>"
> >> >> '// Forget using rcSet.Fields, and just use rcSet
> >> >> '// directly
> >> >> response.write "<p>Welcome " & rcSet(1) & "</p>"
> >> >> else
> >> >> response.write "incorrect Username and/or Password"
> >> >> end if
> >> >>
> >> >> '// Don't forget to cleanup after yourself
> >> >> cnStr.Close: Set cnStr =3D Nothing
> >> >> Set rcSet =3D Nothing
> >> >> %>
> >> >>
> >> >>
> >> >> Regards
> >> >> Malcolm
> >> >>
> >> >>
> >> >> "malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
> >> >> news:4441273b$0$23177$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
> >> >> > UID and PWD are the 2 fields in my database that hold the
> > information.
> >> >> >
> >> >> > I have now changed the code
> >> >> >
> >> >> > "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
> >> >> > news:1145119070.271743.314040 [at] z34g2000cwc.googlegroups.com.. .
> >> >> >>
> >> >> >> malcolm wrote:
> >> >> >>> Hi, while trying to validate username and password on login for=
m I
> > am
> >> >> >>> presented with the following error message
> >> >> >>>
> >> >> >>>
> >> >> >>> Microsoft JET Database Engine error '80040e10'
> >> >> >>>
> >> >> >>> No value given for one or more required parameters.
> >> >> >>>
> >> >> >>> /vdateUsr.asp, line 53
> >> >> >>>
> >> >> >>> The 2 fields within the database are text fields (UID) and (PWD)
> >> >> >>> these
> >> >> >>> are
> >> >> >>> spelt correctly!
> >> >> >>>
> >> >> >>
> >> >> >> <snip>
> >> >> >>> sqlStr =3D "Select * From tblusers where username =3D '" _
> >> >> >>> & Request.Form("UID") & "' and password =3D '" &
> > Request.Form("PWD")
> >> > &
> >> >> >>> "'"
> >> >> >>>
> >> >> >>
> >> >> >> No - they're not spelt correctly. In your SQL statement you re=
fer
> > to
> >> >> >> two fields called username and password, yet you said they are
> > called
> >> >> >> UID and PWD. Which is correct?
> >> >> >>
> >> >> >> --
> >> >> >> Mike Brind
> >> >> >>
> >> >> >
> >> >> >
> >> >>
> >> >>
> >> >
> >> >
> >>
> >>
> >
> >
Re: Validate logins with ASP, MS Access and Cookies error
Thanks Mike,
So if I change my code it would look like this
"Select [prefered_name], UID From tblusers where UID = '" _
& Request.Form("UID") & "' and PWD = '" & Request.Form("PWD") & "'"
The problem I now find with this code is the fact that my old code worked
really well and would re-direct users to the referrer page?? How can I do
that with this code??
The code used in my old page was
<% [at] language="vbscript" %>
<%
' Was this page posted to?
If UCase(Request.ServerVariables("HTTP_METHOD")) = "POST" Then
' If so, check the username/password that was entered.
If ComparePassword(Request("UID"),Request("PWD")) Then
' If comparison was good, store the user name...
Session("UID") = Request("UID")
' ...and redirect back to the original page.
Response.Redirect Session("REFERRER")
End If
End If
%>
Regards
Malcolm
"Mike Brind" <paxtonend [at] hotmail.com> wrote in message
news:1145127899.468752.169210 [at] e56g2000cwe.googlegroups.com.. .
Bad choice of field name. "Name" a reserved word in Access. Steve
Burns posted the correct answer to your question, but it would have
thrown up an error in this case.
Change it if you can, but if not, your sqlStr will have to look like
this:
"Select [name], UID From tblusers where UID = '"
_ & Request.Form("UID") & "' and PWD = '" & Request.Form("PWD") & "'"
Even then, there are other problems with the approach you are taking.
If you copy and paste the following line into the user name and
password fields in your form:
' or ''='
You will always log in successfully. This is a common SQL Injection
attack method. Also, if you have someone who's username contains an
apostophe, you will get errors. The best defence against this is to
use a saved parameter query in your Access database:
http://www.xefteri.com/articles/show.cfm?id=6
--
Mike Brind
malcolm wrote:
> Name is the name of the field and the database is MS access.
>
>
>
> "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
> news:1145125091.697554.101780 [at] v46g2000cwv.googlegroups.com.. .
> Which field in the database holds the user's first name? And what type
> of database are you using?
>
> --
> Mike Brind
>
>
> malcolm wrote:
> > Thanks Guys, i have now cleaned up the code and it is working ok. Just
> > one
> > thing I want to ask! on the login successful page it shows the username
> > aas
> > typed into the form UID field.. what I would like to do now is actully
> > return another column from the database that stores the users 1st name
> > :-)
> >
> > any tips
> >
> > here is the code I am using now. :-)
> >
> > <% [at] Language="VBScript"%>
> >
> > <!-- METADATA TYPE="typelib" FILE="C:\Program Files\Common
> > Files\System\ado\msado15.dll" -->
> > <!-- #include file="Connectionstring.asp" -->
> > <%
> >
> > ' variables
> > dim cnStr, rcSet, frmUID, frmPWD, sqlStr
> >
> > 'store form input into variables
> > frmUID = Request.Form("UID")
> > frmPWD = Request.Form("PWD")
> >
> > 'create connection and recordset objects
> > Set cnStr = Server.CreateObject("ADODB.Connection")
> >
> > ' defining database connection (connectionstring.asp)
> > cnStr.ConnectionString = path
> > cnStr.Provider = provider
> > cnStr.open
> >
> > ' execute sql and open as recordset
> >
> > sqlStr = "Select * From tblusers where UID = '" _
> > & Request.Form("UID") & "' and PWD = '" & Request.Form("PWD") & "'"
> >
> > ' Opens the returned values from the SQL as a recordset,
> > ' ready for iteration by ASP
> > ' validate variables against database
> > // If (not rcSet.BOF) and (not rcSet.EOF) then
> >
> > If Len(frmUID) < 1 Then frmUID = "NULL"
> > If Len(frmPWD) < 1 Then frmPWD = "NULL"
> >
> > Set rcSet = cnStr.Execute(sqlStr)
> >
> > If NOT rcSet.EOF Then
> > response.cookies("validated_user") = frmUID
> > response.write "<h1>Login successful!</h1>"
> >
> > response.write "<p>Welcome " & rcSet(0) & "</p>"
> > else
> > response.write "Incorrect Username and/or Password"
> > end if
> >
> > cnStr.Close: Set cnStr = Nothing
> > Set rcSet = Nothing
> > %>
> >
> > I had to change this code
> > response.write "<p>Welcome " & rcSet(1) & "</p>"
> > to this code
> > response.write "<p>Welcome " & rcSet(0) & "</p>"
> > so that it would display the username and not the password ;-)
> > not bad for a guess. :-)
> >
> > Regards
> > Malcolm
> >
> >
> > "Steven Burn" <somewhere [at] in-time.invalid> wrote in message
> > news:e%237BQOLYGHA.3448 [at] TK2MSFTNGP04.phx.gbl...
> > > Change;
> > >
> > > sqlStr = "Select * From tblusers where UID = '" _
> > > & Request.Form("UID") & "' and PWD = '" & Request.Form("PWD") &
> > > "'"
> > >
> > > ' Opens the returned values from the SQL as a recordset,
> > > ' ready for iteration by ASP
> > > '// <<< LINE 53 >>> set rcSet = cnStr.Execute(sqlStr)
> > > ' validate variables against database
> > > // If (not rcSet.BOF) and (not rcSet.EOF) then
> > >
> > > '// Check before processing
> > > If Len(frmUsername) < 1 Then frmUsername = "NULL"
> > > If Len(frmPassword) < 1 Then frmPassword = "NULL"
> > >
> > > To;
> > >
> > > '// Check before processing
> > > If Len(frmUsername) < 1 Then frmUsername = "NULL"
> > > If Len(frmPassword) < 1 Then frmPassword = "NULL"
> > > Response.Write "<b><i>DEBUG</i><b><br>Username: " _
> > > & frmUID & "<br>Password: " & frmPWD
> > > sqlStr = "Select * From tblusers where UID = '" _
> > > & frmUID & "' and PWD = '" & frmPWD & "'"
> > >
> > > ' Opens the returned values from the SQL as a recordset,
> > > ' ready for iteration by ASP
> > > '// <<< LINE 53 >>> set rcSet = cnStr.Execute(sqlStr)
> > > ' validate variables against database
> > > // If (not rcSet.BOF) and (not rcSet.EOF) then
> > >
> > > --
> > > Regards
> > >
> > > Steven Burn
> > > Ur I.T. Mate Group
> > > www.it-mate.co.uk
> > >
> > > Keeping it FREE!
> > >
> > > "malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
> > > news:4441284e$0$23185$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
> > >> I am now presented with incorrect Username and/or Password. I have
> > >> double
> > >> checked this.
> > >>
> > >> I now have the following code in my page
> > >>
> > >> <% [at] Language="VBScript"%>
> > >>
> > >> <!-- METADATA TYPE="typelib" FILE="C:\Program Files\Common
> > >> Files\System\ado\msado15.dll" -->
> > >> <!-- #include file="Connectionstring.asp" -->
> > >> <%
> > >> ' /////////////////////////////////////
> > >> ' login validation script
> > >> ' © Matt Millross
> > >> ' www.designplace.org
> > >> ' free for use as long as copyright notice left intact
> > >> ' For more scripts, visit www.designplace.org
> > >> ' /////////////////////////////////////
> > >>
> > >> ' variables
> > >> dim cnStr, rcSet, frmUID, frmPWD, sqlStr
> > >>
> > >> 'store form input into variables
> > >> frmUID = Request.Form("UID")
> > >> frmPWD = Request.Form("PWD")
> > >>
> > >> 'create connection and recordset objects
> > >> Set cnStr = Server.CreateObject("ADODB.Connection")
> > >> '// THIS IS NOT NEEDED!
> > >> '// Set rcSet = Server.CreateObject("ADODB.Recordset")
> > >>
> > >> ' defining database connection (connectionstring.asp)
> > >> cnStr.ConnectionString = path
> > >> cnStr.Provider = provider
> > >> cnStr.open
> > >>
> > >> ' execute sql and open as recordset
> > >> '// sqlStr = "Select * From tblusers where username = '" _
> > >> '// & Request.Form("UID") & "' and password = '" &
> > >> Request.Form("PWD")
> > >> &
> > >> "'"
> > >> '// You've already stored the user/pass into a local var - use them!
> > >> '// and NEVER use "Select * ..."
> > >> '//
> > >> '// http://aspfaq.com/show.asp?id 96
> > >>
> > >> sqlStr = "Select * From tblusers where UID = '" _
> > >> & Request.Form("UID") & "' and PWD = '" & Request.Form("PWD") &
> > >> "'"
> > >>
> > >> ' Opens the returned values from the SQL as a recordset,
> > >> ' ready for iteration by ASP
> > >> '// <<< LINE 53 >>> set rcSet = cnStr.Execute(sqlStr)
> > >> ' validate variables against database
> > >> // If (not rcSet.BOF) and (not rcSet.EOF) then
> > >>
> > >> '// Check before processing
> > >> If Len(frmUsername) < 1 Then frmUsername = "NULL"
> > >> If Len(frmPassword) < 1 Then frmPassword = "NULL"
> > >> '// Then go...
> > >> Set rcSet = cnStr.Execute(sqlStr)
> > >>
> > >> If NOT rcSet.EOF Then
> > >> response.cookies("validated_user") = frmUID
> > >> response.write "<h1>Login successful!</h1>"
> > >> '// Forget using rcSet.Fields, and just use rcSet
> > >> '// directly
> > >> response.write "<p>Welcome " & rcSet(1) & "</p>"
> > >> else
> > >> response.write "incorrect Username and/or Password"
> > >> end if
> > >>
> > >> '// Don't forget to cleanup after yourself
> > >> cnStr.Close: Set cnStr = Nothing
> > >> Set rcSet = Nothing
> > >> %>
> > >>
> > >>
> > >> Regards
> > >> Malcolm
> > >>
> > >>
> > >> "malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
> > >> news:4441273b$0$23177$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
> > >> > UID and PWD are the 2 fields in my database that hold the
> > >> > information.
> > >> >
> > >> > I have now changed the code
> > >> >
> > >> > "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
> > >> > news:1145119070.271743.314040 [at] z34g2000cwc.googlegroups.com.. .
> > >> >>
> > >> >> malcolm wrote:
> > >> >>> Hi, while trying to validate username and password on login form
> > >> >>> I
> > >> >>> am
> > >> >>> presented with the following error message
> > >> >>>
> > >> >>>
> > >> >>> Microsoft JET Database Engine error '80040e10'
> > >> >>>
> > >> >>> No value given for one or more required parameters.
> > >> >>>
> > >> >>> /vdateUsr.asp, line 53
> > >> >>>
> > >> >>> The 2 fields within the database are text fields (UID) and (PWD)
> > >> >>> these
> > >> >>> are
> > >> >>> spelt correctly!
> > >> >>>
> > >> >>
> > >> >> <snip>
> > >> >>> sqlStr = "Select * From tblusers where username = '" _
> > >> >>> & Request.Form("UID") & "' and password = '" &
> > >> >>> Request.Form("PWD")
> > > &
> > >> >>> "'"
> > >> >>>
> > >> >>
> > >> >> No - they're not spelt correctly. In your SQL statement you
> > >> >> refer
> > >> >> to
> > >> >> two fields called username and password, yet you said they are
> > >> >> called
> > >> >> UID and PWD. Which is correct?
> > >> >>
> > >> >> --
> > >> >> Mike Brind
> > >> >>
> > >> >
> > >> >
> > >>
> > >>
> > >
> > >
Re: Validate logins with ASP, MS Access and Cookies error
You would only have to put [ ] brackets around the field name if you
are using a reserved word, or have an embedded space in the field name.
If "prefered_name" is the new name for that field, you can leave the
brackets off.
Wrt the new bit of code you just posted, what do you want it to
actually do? It looks to me as if that was part of a system where
people filled out a form on one page, it posted to another for
processing, then if the login was successful, it sent them back to the
first page again. Is that right? And if so, is that what you still
want to happen?
--
Mike Brind
malcolm wrote:
> Thanks Mike,
>
> So if I change my code it would look like this
>
>
>
> "Select [prefered_name], UID From tblusers where UID =3D '" _
>
> & Request.Form("UID") & "' and PWD =3D '" & Request.Form("PWD") &=
"'"
>
>
>
> The problem I now find with this code is the fact that my old code worked
> really well and would re-direct users to the referrer page?? How can I do
> that with this code??
>
>
>
> The code used in my old page was
>
>
>
> <% [at] language=3D"vbscript" %>
>
>
>
> <%
>
> ' Was this page posted to?
>
> If UCase(Request.ServerVariables("HTTP_METHOD")) =3D "POST" Then
>
> ' If so, check the username/password that was entered.
>
> If ComparePassword(Request("UID"),Request("PWD")) Then
>
> ' If comparison was good, store the user name...
>
> Session("UID") =3D Request("UID")
>
> ' ...and redirect back to the original page.
>
> Response.Redirect Session("REFERRER")
>
> End If
>
> End If
>
> %>
>
>
>
> Regards
>
> Malcolm
>
>
> "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
> news:1145127899.468752.169210 [at] e56g2000cwe.googlegroups.com.. .
> Bad choice of field name. "Name" a reserved word in Access. Steve
> Burns posted the correct answer to your question, but it would have
> thrown up an error in this case.
>
> Change it if you can, but if not, your sqlStr will have to look like
> this:
>
> "Select [name], UID From tblusers where UID =3D '"
> _ & Request.Form("UID") & "' and PWD =3D '" & Request.Form("PWD") & "'"
>
> Even then, there are other problems with the approach you are taking.
> If you copy and paste the following line into the user name and
> password fields in your form:
>
> ' or ''=3D'
>
> You will always log in successfully. This is a common SQL Injection
> attack method. Also, if you have someone who's username contains an
> apostophe, you will get errors. The best defence against this is to
> use a saved parameter query in your Access database:
>
> http://www.xefteri.com/articles/show.cfm?id=3D6
>
> --
> Mike Brind
>
>
> malcolm wrote:
> > Name is the name of the field and the database is MS access.
> >
> >
> >
> > "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
> > news:1145125091.697554.101780 [at] v46g2000cwv.googlegroups.com.. .
> > Which field in the database holds the user's first name? And what type
> > of database are you using?
> >
> > --
> > Mike Brind
> >
> >
> > malcolm wrote:
> > > Thanks Guys, i have now cleaned up the code and it is working ok. Just
> > > one
> > > thing I want to ask! on the login successful page it shows the userna=
me
> > > aas
> > > typed into the form UID field.. what I would like to do now is actully
> > > return another column from the database that stores the users 1st name
> > > :-)
> > >
> > > any tips
> > >
> > > here is the code I am using now. :-)
> > >
> > > <% [at] Language=3D"VBScript"%>
> > >
> > > <!-- METADATA TYPE=3D"typelib" FILE=3D"C:\Program Files\Common
> > > Files\System\ado\msado15.dll" -->
> > > <!-- #include file=3D"Connectionstring.asp" -->
> > > <%
> > >
> > > ' variables
> > > dim cnStr, rcSet, frmUID, frmPWD, sqlStr
> > >
> > > 'store form input into variables
> > > frmUID =3D Request.Form("UID")
> > > frmPWD =3D Request.Form("PWD")
> > >
> > > 'create connection and recordset objects
> > > Set cnStr =3D Server.CreateObject("ADODB.Connection")
> > >
> > > ' defining database connection (connectionstring.asp)
> > > cnStr.ConnectionString =3D path
> > > cnStr.Provider =3D provider
> > > cnStr.open
> > >
> > > ' execute sql and open as recordset
> > >
> > > sqlStr =3D "Select * From tblusers where UID =3D '" _
> > > & Request.Form("UID") & "' and PWD =3D '" & Request.Form("PWD") =
& "'"
> > >
> > > ' Opens the returned values from the SQL as a recordset,
> > > ' ready for iteration by ASP
> > > ' validate variables against database
> > > // If (not rcSet.BOF) and (not rcSet.EOF) then
> > >
> > > If Len(frmUID) < 1 Then frmUID =3D "NULL"
> > > If Len(frmPWD) < 1 Then frmPWD =3D "NULL"
> > >
> > > Set rcSet =3D cnStr.Execute(sqlStr)
> > >
> > > If NOT rcSet.EOF Then
> > > response.cookies("validated_user") =3D frmUID
> > > response.write "<h1>Login successful!</h1>"
> > >
> > > response.write "<p>Welcome " & rcSet(0) & "</p>"
> > > else
> > > response.write "Incorrect Username and/or Password"
> > > end if
> > >
> > > cnStr.Close: Set cnStr =3D Nothing
> > > Set rcSet =3D Nothing
> > > %>
> > >
> > > I had to change this code
> > > response.write "<p>Welcome " & rcSet(1) & "</p>"
> > > to this code
> > > response.write "<p>Welcome " & rcSet(0) & "</p>"
> > > so that it would display the username and not the password ;-)
> > > not bad for a guess. :-)
> > >
> > > Regards
> > > Malcolm
> > >
> > >
> > > "Steven Burn" <somewhere [at] in-time.invalid> wrote in message
> > > news:e%237BQOLYGHA.3448 [at] TK2MSFTNGP04.phx.gbl...
> > > > Change;
> > > >
> > > > sqlStr =3D "Select * From tblusers where UID =3D '" _
> > > > & Request.Form("UID") & "' and PWD =3D '" & Request.Form("PWD")=
&
> > > > "'"
> > > >
> > > > ' Opens the returned values from the SQL as a recordset,
> > > > ' ready for iteration by ASP
> > > > '// <<< LINE 53 >>> set rcSet =3D cnStr.Execute(sqlStr)
> > > > ' validate variables against database
> > > > // If (not rcSet.BOF) and (not rcSet.EOF) then
> > > >
> > > > '// Check before processing
> > > > If Len(frmUsername) < 1 Then frmUsername =3D "NULL"
> > > > If Len(frmPassword) < 1 Then frmPassword =3D "NULL"
> > > >
> > > > To;
> > > >
> > > > '// Check before processing
> > > > If Len(frmUsername) < 1 Then frmUsername =3D "NULL"
> > > > If Len(frmPassword) < 1 Then frmPassword =3D "NULL"
> > > > Response.Write "<b><i>DEBUG</i><b><br>Username: " _
> > > > & frmUID & "<br>Password: " & frmPWD
> > > > sqlStr =3D "Select * From tblusers where UID =3D '" _
> > > > & frmUID & "' and PWD =3D '" & frmPWD & "'"
> > > >
> > > > ' Opens the returned values from the SQL as a recordset,
> > > > ' ready for iteration by ASP
> > > > '// <<< LINE 53 >>> set rcSet =3D cnStr.Execute(sqlStr)
> > > > ' validate variables against database
> > > > // If (not rcSet.BOF) and (not rcSet.EOF) then
> > > >
> > > > --
> > > > Regards
> > > >
> > > > Steven Burn
> > > > Ur I.T. Mate Group
> > > > www.it-mate.co.uk
> > > >
> > > > Keeping it FREE!
> > > >
> > > > "malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
> > > > news:4441284e$0$23185$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
> > > >> I am now presented with incorrect Username and/or Password. I have
> > > >> double
> > > >> checked this.
> > > >>
> > > >> I now have the following code in my page
> > > >>
> > > >> <% [at] Language=3D"VBScript"%>
> > > >>
> > > >> <!-- METADATA TYPE=3D"typelib" FILE=3D"C:\Program Files\Common
> > > >> Files\System\ado\msado15.dll" -->
> > > >> <!-- #include file=3D"Connectionstring.asp" -->
> > > >> <%
> > > >> ' /////////////////////////////////////
> > > >> ' login validation script
> > > >> ' =A9 Matt Millross
> > > >> ' www.designplace.org
> > > >> ' free for use as long as copyright notice left intact
> > > >> ' For more scripts, visit www.designplace.org
> > > >> ' /////////////////////////////////////
> > > >>
> > > >> ' variables
> > > >> dim cnStr, rcSet, frmUID, frmPWD, sqlStr
> > > >>
> > > >> 'store form input into variables
> > > >> frmUID =3D Request.Form("UID")
> > > >> frmPWD =3D Request.Form("PWD")
> > > >>
> > > >> 'create connection and recordset objects
> > > >> Set cnStr =3D Server.CreateObject("ADODB.Connection")
> > > >> '// THIS IS NOT NEEDED!
> > > >> '// Set rcSet =3D Server.CreateObject("ADODB.Recordset")
> > > >>
> > > >> ' defining database connection (connectionstring.asp)
> > > >> cnStr.ConnectionString =3D path
> > > >> cnStr.Provider =3D provider
> > > >> cnStr.open
> > > >>
> > > >> ' execute sql and open as recordset
> > > >> '// sqlStr =3D "Select * From tblusers where username =3D '" _
> > > >> '// & Request.Form("UID") & "' and password =3D '" &
> > > >> Request.Form("PWD")
> > > >> &
> > > >> "'"
> > > >> '// You've already stored the user/pass into a local var - use the=
m!
> > > >> '// and NEVER use "Select * ..."
> > > >> '//
> > > >> '// http://aspfaq.com/show.asp?id=3D2096
> > > >>
> > > >> sqlStr =3D "Select * From tblusers where UID =3D '" _
> > > >> & Request.Form("UID") & "' and PWD =3D '" & Request.Form("PWD=
") &
> > > >> "'"
> > > >>
> > > >> ' Opens the returned values from the SQL as a recordset,
> > > >> ' ready for iteration by ASP
> > > >> '// <<< LINE 53 >>> set rcSet =3D cnStr.Execute(sqlStr)
> > > >> ' validate variables against database
> > > >> // If (not rcSet.BOF) and (not rcSet.EOF) then
> > > >>
> > > >> '// Check before processing
> > > >> If Len(frmUsername) < 1 Then frmUsername =3D "NULL"
> > > >> If Len(frmPassword) < 1 Then frmPassword =3D "NULL"
> > > >> '// Then go...
> > > >> Set rcSet =3D cnStr.Execute(sqlStr)
> > > >>
> > > >> If NOT rcSet.EOF Then
> > > >> response.cookies("validated_user") =3D frmUID
> > > >> response.write "<h1>Login successful!</h1>"
> > > >> '// Forget using rcSet.Fields, and just use rcSet
> > > >> '// directly
> > > >> response.write "<p>Welcome " & rcSet(1) & "</p>"
> > > >> else
> > > >> response.write "incorrect Username and/or Password"
> > > >> end if
> > > >>
> > > >> '// Don't forget to cleanup after yourself
> > > >> cnStr.Close: Set cnStr =3D Nothing
> > > >> Set rcSet =3D Nothing
> > > >> %>
> > > >>
> > > >>
> > > >> Regards
> > > >> Malcolm
> > > >>
> > > >>
> > > >> "malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
> > > >> news:4441273b$0$23177$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
> > > >> > UID and PWD are the 2 fields in my database that hold the
> > > >> > information.
> > > >> >
> > > >> > I have now changed the code
> > > >> >
> > > >> > "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
> > > >> > news:1145119070.271743.314040 [at] z34g2000cwc.googlegroups.com.. .
> > > >> >>
> > > >> >> malcolm wrote:
> > > >> >>> Hi, while trying to validate username and password on login fo=
rm
> > > >> >>> I
> > > >> >>> am
> > > >> >>> presented with the following error message
> > > >> >>>
> > > >> >>>
> > > >> >>> Microsoft JET Database Engine error '80040e10'
> > > >> >>>
> > > >> >>> No value given for one or more required parameters.
> > > >> >>>
> > > >> >>> /vdateUsr.asp, line 53
> > > >> >>>
> > > >> >>> The 2 fields within the database are text fields (UID) and (PW=
D)
> > > >> >>> these
> > > >> >>> are
> > > >> >>> spelt correctly!
> > > >> >>>
> > > >> >>
> > > >> >> <snip>
> > > >> >>> sqlStr =3D "Select * From tblusers where username =3D '" _
> > > >> >>> & Request.Form("UID") & "' and password =3D '" &
> > > >> >>> Request.Form("PWD")
> > > > &
> > > >> >>> "'"
> > > >> >>>
> > > >> >>
> > > >> >> No - they're not spelt correctly. In your SQL statement you
> > > >> >> refer
> > > >> >> to
> > > >> >> two fields called username and password, yet you said they are
> > > >> >> called
> > > >> >> UID and PWD. Which is correct?
> > > >> >>
> > > >> >> --
> > > >> >> Mike Brind
> > > >> >>
> > > >> >
> > > >> >
> > > >>
> > > >>
> > > >
> > > >
Re: Validate logins with ASP, MS Access and Cookies error
Yes.
I used that system to do just that Mike... Not sure waht to do now as it
will not work!
Malcolm
"Mike Brind" <paxtonend [at] hotmail.com> wrote in message
news:1145132830.519120.327380 [at] z34g2000cwc.googlegroups.com.. .
You would only have to put [ ] brackets around the field name if you
are using a reserved word, or have an embedded space in the field name.
If "prefered_name" is the new name for that field, you can leave the
brackets off.
Wrt the new bit of code you just posted, what do you want it to
actually do? It looks to me as if that was part of a system where
people filled out a form on one page, it posted to another for
processing, then if the login was successful, it sent them back to the
first page again. Is that right? And if so, is that what you still
want to happen?
--
Mike Brind
malcolm wrote:
> Thanks Mike,
>
> So if I change my code it would look like this
>
>
>
> "Select [prefered_name], UID From tblusers where UID = '" _
>
> & Request.Form("UID") & "' and PWD = '" & Request.Form("PWD") &
> "'"
>
>
>
> The problem I now find with this code is the fact that my old code worked
> really well and would re-direct users to the referrer page?? How can I do
> that with this code??
>
>
>
> The code used in my old page was
>
>
>
> <% [at] language="vbscript" %>
>
>
>
> <%
>
> ' Was this page posted to?
>
> If UCase(Request.ServerVariables("HTTP_METHOD")) = "POST" Then
>
> ' If so, check the username/password that was entered.
>
> If ComparePassword(Request("UID"),Request("PWD")) Then
>
> ' If comparison was good, store the user name...
>
> Session("UID") = Request("UID")
>
> ' ...and redirect back to the original page.
>
> Response.Redirect Session("REFERRER")
>
> End If
>
> End If
>
> %>
>
>
>
> Regards
>
> Malcolm
>
>
> "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
> news:1145127899.468752.169210 [at] e56g2000cwe.googlegroups.com.. .
> Bad choice of field name. "Name" a reserved word in Access. Steve
> Burns posted the correct answer to your question, but it would have
> thrown up an error in this case.
>
> Change it if you can, but if not, your sqlStr will have to look like
> this:
>
> "Select [name], UID From tblusers where UID = '"
> _ & Request.Form("UID") & "' and PWD = '" & Request.Form("PWD") & "'"
>
> Even then, there are other problems with the approach you are taking.
> If you copy and paste the following line into the user name and
> password fields in your form:
>
> ' or ''='
>
> You will always log in successfully. This is a common SQL Injection
> attack method. Also, if you have someone who's username contains an
> apostophe, you will get errors. The best defence against this is to
> use a saved parameter query in your Access database:
>
> http://www.xefteri.com/articles/show.cfm?id=6
>
> --
> Mike Brind
>
>
> malcolm wrote:
> > Name is the name of the field and the database is MS access.
> >
> >
> >
> > "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
> > news:1145125091.697554.101780 [at] v46g2000cwv.googlegroups.com.. .
> > Which field in the database holds the user's first name? And what type
> > of database are you using?
> >
> > --
> > Mike Brind
> >
> >
> > malcolm wrote:
> > > Thanks Guys, i have now cleaned up the code and it is working ok. Just
> > > one
> > > thing I want to ask! on the login successful page it shows the
> > > username
> > > aas
> > > typed into the form UID field.. what I would like to do now is actully
> > > return another column from the database that stores the users 1st name
> > > :-)
> > >
> > > any tips
> > >
> > > here is the code I am using now. :-)
> > >
> > > <% [at] Language="VBScript"%>
> > >
> > > <!-- METADATA TYPE="typelib" FILE="C:\Program Files\Common
> > > Files\System\ado\msado15.dll" -->
> > > <!-- #include file="Connectionstring.asp" -->
> > > <%
> > >
> > > ' variables
> > > dim cnStr, rcSet, frmUID, frmPWD, sqlStr
> > >
> > > 'store form input into variables
> > > frmUID = Request.Form("UID")
> > > frmPWD = Request.Form("PWD")
> > >
> > > 'create connection and recordset objects
> > > Set cnStr = Server.CreateObject("ADODB.Connection")
> > >
> > > ' defining database connection (connectionstring.asp)
> > > cnStr.ConnectionString = path
> > > cnStr.Provider = provider
> > > cnStr.open
> > >
> > > ' execute sql and open as recordset
> > >
> > > sqlStr = "Select * From tblusers where UID = '" _
> > > & Request.Form("UID") & "' and PWD = '" & Request.Form("PWD") &
> > > "'"
> > >
> > > ' Opens the returned values from the SQL as a recordset,
> > > ' ready for iteration by ASP
> > > ' validate variables against database
> > > // If (not rcSet.BOF) and (not rcSet.EOF) then
> > >
> > > If Len(frmUID) < 1 Then frmUID = "NULL"
> > > If Len(frmPWD) < 1 Then frmPWD = "NULL"
> > >
> > > Set rcSet = cnStr.Execute(sqlStr)
> > >
> > > If NOT rcSet.EOF Then
> > > response.cookies("validated_user") = frmUID
> > > response.write "<h1>Login successful!</h1>"
> > >
> > > response.write "<p>Welcome " & rcSet(0) & "</p>"
> > > else
> > > response.write "Incorrect Username and/or Password"
> > > end if
> > >
> > > cnStr.Close: Set cnStr = Nothing
> > > Set rcSet = Nothing
> > > %>
> > >
> > > I had to change this code
> > > response.write "<p>Welcome " & rcSet(1) & "</p>"
> > > to this code
> > > response.write "<p>Welcome " & rcSet(0) & "</p>"
> > > so that it would display the username and not the password ;-)
> > > not bad for a guess. :-)
> > >
> > > Regards
> > > Malcolm
> > >
> > >
> > > "Steven Burn" <somewhere [at] in-time.invalid> wrote in message
> > > news:e%237BQOLYGHA.3448 [at] TK2MSFTNGP04.phx.gbl...
> > > > Change;
> > > >
> > > > sqlStr = "Select * From tblusers where UID = '" _
> > > > & Request.Form("UID") & "' and PWD = '" & Request.Form("PWD") &
> > > > "'"
> > > >
> > > > ' Opens the returned values from the SQL as a recordset,
> > > > ' ready for iteration by ASP
> > > > '// <<< LINE 53 >>> set rcSet = cnStr.Execute(sqlStr)
> > > > ' validate variables against database
> > > > // If (not rcSet.BOF) and (not rcSet.EOF) then
> > > >
> > > > '// Check before processing
> > > > If Len(frmUsername) < 1 Then frmUsername = "NULL"
> > > > If Len(frmPassword) < 1 Then frmPassword = "NULL"
> > > >
> > > > To;
> > > >
> > > > '// Check before processing
> > > > If Len(frmUsername) < 1 Then frmUsername = "NULL"
> > > > If Len(frmPassword) < 1 Then frmPassword = "NULL"
> > > > Response.Write "<b><i>DEBUG</i><b><br>Username: " _
> > > > & frmUID & "<br>Password: " & frmPWD
> > > > sqlStr = "Select * From tblusers where UID = '" _
> > > > & frmUID & "' and PWD = '" & frmPWD & "'"
> > > >
> > > > ' Opens the returned values from the SQL as a recordset,
> > > > ' ready for iteration by ASP
> > > > '// <<< LINE 53 >>> set rcSet = cnStr.Execute(sqlStr)
> > > > ' validate variables against database
> > > > // If (not rcSet.BOF) and (not rcSet.EOF) then
> > > >
> > > > --
> > > > Regards
> > > >
> > > > Steven Burn
> > > > Ur I.T. Mate Group
> > > > www.it-mate.co.uk
> > > >
> > > > Keeping it FREE!
> > > >
> > > > "malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
> > > > news:4441284e$0$23185$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
> > > >> I am now presented with incorrect Username and/or Password. I have
> > > >> double
> > > >> checked this.
> > > >>
> > > >> I now have the following code in my page
> > > >>
> > > >> <% [at] Language="VBScript"%>
> > > >>
> > > >> <!-- METADATA TYPE="typelib" FILE="C:\Program Files\Common
> > > >> Files\System\ado\msado15.dll" -->
> > > >> <!-- #include file="Connectionstring.asp" -->
> > > >> <%
> > > >> ' /////////////////////////////////////
> > > >> ' login validation script
> > > >> ' © Matt Millross
> > > >> ' www.designplace.org
> > > >> ' free for use as long as copyright notice left intact
> > > >> ' For more scripts, visit www.designplace.org
> > > >> ' /////////////////////////////////////
> > > >>
> > > >> ' variables
> > > >> dim cnStr, rcSet, frmUID, frmPWD, sqlStr
> > > >>
> > > >> 'store form input into variables
> > > >> frmUID = Request.Form("UID")
> > > >> frmPWD = Request.Form("PWD")
> > > >>
> > > >> 'create connection and recordset objects
> > > >> Set cnStr = Server.CreateObject("ADODB.Connection")
> > > >> '// THIS IS NOT NEEDED!
> > > >> '// Set rcSet = Server.CreateObject("ADODB.Recordset")
> > > >>
> > > >> ' defining database connection (connectionstring.asp)
> > > >> cnStr.ConnectionString = path
> > > >> cnStr.Provider = provider
> > > >> cnStr.open
> > > >>
> > > >> ' execute sql and open as recordset
> > > >> '// sqlStr = "Select * From tblusers where username = '" _
> > > >> '// & Request.Form("UID") & "' and password = '" &
> > > >> Request.Form("PWD")
> > > >> &
> > > >> "'"
> > > >> '// You've already stored the user/pass into a local var - use
> > > >> them!
> > > >> '// and NEVER use "Select * ..."
> > > >> '//
> > > >> '// http://aspfaq.com/show.asp?id 96
> > > >>
> > > >> sqlStr = "Select * From tblusers where UID = '" _
> > > >> & Request.Form("UID") & "' and PWD = '" & Request.Form("PWD")
> > > >> &
> > > >> "'"
> > > >>
> > > >> ' Opens the returned values from the SQL as a recordset,
> > > >> ' ready for iteration by ASP
> > > >> '// <<< LINE 53 >>> set rcSet = cnStr.Execute(sqlStr)
> > > >> ' validate variables against database
> > > >> // If (not rcSet.BOF) and (not rcSet.EOF) then
> > > >>
> > > >> '// Check before processing
> > > >> If Len(frmUsername) < 1 Then frmUsername = "NULL"
> > > >> If Len(frmPassword) < 1 Then frmPassword = "NULL"
> > > >> '// Then go...
> > > >> Set rcSet = cnStr.Execute(sqlStr)
> > > >>
> > > >> If NOT rcSet.EOF Then
> > > >> response.cookies("validated_user") = frmUID
> > > >> response.write "<h1>Login successful!</h1>"
> > > >> '// Forget using rcSet.Fields, and just use rcSet
> > > >> '// directly
> > > >> response.write "<p>Welcome " & rcSet(1) & "</p>"
> > > >> else
> > > >> response.write "incorrect Username and/or Password"
> > > >> end if
> > > >>
> > > >> '// Don't forget to cleanup after yourself
> > > >> cnStr.Close: Set cnStr = Nothing
> > > >> Set rcSet = Nothing
> > > >> %>
> > > >>
> > > >>
> > > >> Regards
> > > >> Malcolm
> > > >>
> > > >>
> > > >> "malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
> > > >> news:4441273b$0$23177$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
> > > >> > UID and PWD are the 2 fields in my database that hold the
> > > >> > information.
> > > >> >
> > > >> > I have now changed the code
> > > >> >
> > > >> > "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
> > > >> > news:1145119070.271743.314040 [at] z34g2000cwc.googlegroups.com.. .
> > > >> >>
> > > >> >> malcolm wrote:
> > > >> >>> Hi, while trying to validate username and password on login
> > > >> >>> form
> > > >> >>> I
> > > >> >>> am
> > > >> >>> presented with the following error message
> > > >> >>>
> > > >> >>>
> > > >> >>> Microsoft JET Database Engine error '80040e10'
> > > >> >>>
> > > >> >>> No value given for one or more required parameters.
> > > >> >>>
> > > >> >>> /vdateUsr.asp, line 53
> > > >> >>>
> > > >> >>> The 2 fields within the database are text fields (UID) and
> > > >> >>> (PWD)
> > > >> >>> these
> > > >> >>> are
> > > >> >>> spelt correctly!
> > > >> >>>
> > > >> >>
> > > >> >> <snip>
> > > >> >>> sqlStr = "Select * From tblusers where username = '" _
> > > >> >>> & Request.Form("UID") & "' and password = '" &
> > > >> >>> Request.Form("PWD")
> > > > &
> > > >> >>> "'"
> > > >> >>>
> > > >> >>
> > > >> >> No - they're not spelt correctly. In your SQL statement you
> > > >> >> refer
> > > >> >> to
> > > >> >> two fields called username and password, yet you said they are
> > > >> >> called
> > > >> >> UID and PWD. Which is correct?
> > > >> >>
> > > >> >> --
> > > >> >> Mike Brind
> > > >> >>
> > > >> >
> > > >> >
> > > >>
> > > >>
> > > >
> > > >
Re: Validate logins with ASP, MS Access and Cookies error
Woot!, another PN customer <g>
If you are simply wanting to verify authentication, and re-dir on success,
then change;
> If NOT rcSet.EOF Then
> response.cookies("validated_user") = frmUID
> response.write "<h1>Login successful!</h1>"
> '// Forget using rcSet.Fields, and just use rcSet
> '// directly
> response.write "<p>Welcome " & rcSet(1) & "</p>"
> else
> response.write "incorrect Username and/or Password"
> end if
To;
If NOT rcSet.EOF Then
Dim sRef: sRef = Request.ServerVariables("HTTP_REFERER")
Response.cookies("validated_user") = frmUID
Response.Redirect sRef
Else
Response.write "incorrect Username and/or Password"
End if
--
Regards
Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk
Keeping it FREE!
"malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
news:444159c7$0$33896$ed2619ec [at] ptn-nntp-reader03.plus.net...
> Yes.
> I used that system to do just that Mike... Not sure waht to do now as it
> will not work!
>
>
> Malcolm
>
>
> "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
> news:1145132830.519120.327380 [at] z34g2000cwc.googlegroups.com.. .
> You would only have to put [ ] brackets around the field name if you
> are using a reserved word, or have an embedded space in the field name.
> If "prefered_name" is the new name for that field, you can leave the
> brackets off.
>
> Wrt the new bit of code you just posted, what do you want it to
> actually do? It looks to me as if that was part of a system where
> people filled out a form on one page, it posted to another for
> processing, then if the login was successful, it sent them back to the
> first page again. Is that right? And if so, is that what you still
> want to happen?
>
> --
> Mike Brind
>
>
>
> malcolm wrote:
> > Thanks Mike,
> >
> > So if I change my code it would look like this
> >
> >
> >
> > "Select [prefered_name], UID From tblusers where UID = '" _
> >
> > & Request.Form("UID") & "' and PWD = '" & Request.Form("PWD") &
> > "'"
> >
> >
> >
> > The problem I now find with this code is the fact that my old code
worked
> > really well and would re-direct users to the referrer page?? How can I
do
> > that with this code??
> >
> >
> >
> > The code used in my old page was
> >
> >
> >
> > <% [at] language="vbscript" %>
> >
> >
> >
> > <%
> >
> > ' Was this page posted to?
> >
> > If UCase(Request.ServerVariables("HTTP_METHOD")) = "POST" Then
> >
> > ' If so, check the username/password that was entered.
> >
> > If ComparePassword(Request("UID"),Request("PWD")) Then
> >
> > ' If comparison was good, store the user name...
> >
> > Session("UID") = Request("UID")
> >
> > ' ...and redirect back to the original page.
> >
> > Response.Redirect Session("REFERRER")
> >
> > End If
> >
> > End If
> >
> > %>
> >
> >
> >
> > Regards
> >
> > Malcolm
> >
> >
> > "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
> > news:1145127899.468752.169210 [at] e56g2000cwe.googlegroups.com.. .
> > Bad choice of field name. "Name" a reserved word in Access. Steve
> > Burns posted the correct answer to your question, but it would have
> > thrown up an error in this case.
> >
> > Change it if you can, but if not, your sqlStr will have to look like
> > this:
> >
> > "Select [name], UID From tblusers where UID = '"
> > _ & Request.Form("UID") & "' and PWD = '" & Request.Form("PWD") & "'"
> >
> > Even then, there are other problems with the approach you are taking.
> > If you copy and paste the following line into the user name and
> > password fields in your form:
> >
> > ' or ''='
> >
> > You will always log in successfully. This is a common SQL Injection
> > attack method. Also, if you have someone who's username contains an
> > apostophe, you will get errors. The best defence against this is to
> > use a saved parameter query in your Access database:
> >
> > http://www.xefteri.com/articles/show.cfm?id=6
> >
> > --
> > Mike Brind
> >
> >
> > malcolm wrote:
> > > Name is the name of the field and the database is MS access.
> > >
> > >
> > >
> > > "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
> > > news:1145125091.697554.101780 [at] v46g2000cwv.googlegroups.com.. .
> > > Which field in the database holds the user's first name? And what
type
> > > of database are you using?
> > >
> > > --
> > > Mike Brind
> > >
> > >
> > > malcolm wrote:
> > > > Thanks Guys, i have now cleaned up the code and it is working ok.
Just
> > > > one
> > > > thing I want to ask! on the login successful page it shows the
> > > > username
> > > > aas
> > > > typed into the form UID field.. what I would like to do now is
actully
> > > > return another column from the database that stores the users 1st
name
> > > > :-)
> > > >
> > > > any tips
> > > >
> > > > here is the code I am using now. :-)
> > > >
> > > > <% [at] Language="VBScript"%>
> > > >
> > > > <!-- METADATA TYPE="typelib" FILE="C:\Program Files\Common
> > > > Files\System\ado\msado15.dll" -->
> > > > <!-- #include file="Connectionstring.asp" -->
> > > > <%
> > > >
> > > > ' variables
> > > > dim cnStr, rcSet, frmUID, frmPWD, sqlStr
> > > >
> > > > 'store form input into variables
> > > > frmUID = Request.Form("UID")
> > > > frmPWD = Request.Form("PWD")
> > > >
> > > > 'create connection and recordset objects
> > > > Set cnStr = Server.CreateObject("ADODB.Connection")
> > > >
> > > > ' defining database connection (connectionstring.asp)
> > > > cnStr.ConnectionString = path
> > > > cnStr.Provider = provider
> > > > cnStr.open
> > > >
> > > > ' execute sql and open as recordset
> > > >
> > > > sqlStr = "Select * From tblusers where UID = '" _
> > > > & Request.Form("UID") & "' and PWD = '" & Request.Form("PWD") &
> > > > "'"
> > > >
> > > > ' Opens the returned values from the SQL as a recordset,
> > > > ' ready for iteration by ASP
> > > > ' validate variables against database
> > > > // If (not rcSet.BOF) and (not rcSet.EOF) then
> > > >
> > > > If Len(frmUID) < 1 Then frmUID = "NULL"
> > > > If Len(frmPWD) < 1 Then frmPWD = "NULL"
> > > >
> > > > Set rcSet = cnStr.Execute(sqlStr)
> > > >
> > > > If NOT rcSet.EOF Then
> > > > response.cookies("validated_user") = frmUID
> > > > response.write "<h1>Login successful!</h1>"
> > > >
> > > > response.write "<p>Welcome " & rcSet(0) & "</p>"
> > > > else
> > > > response.write "Incorrect Username and/or Password"
> > > > end if
> > > >
> > > > cnStr.Close: Set cnStr = Nothing
> > > > Set rcSet = Nothing
> > > > %>
> > > >
> > > > I had to change this code
> > > > response.write "<p>Welcome " & rcSet(1) & "</p>"
> > > > to this code
> > > > response.write "<p>Welcome " & rcSet(0) & "</p>"
> > > > so that it would display the username and not the password ;-)
> > > > not bad for a guess. :-)
> > > >
> > > > Regards
> > > > Malcolm
> > > >
> > > >
> > > > "Steven Burn" <somewhere [at] in-time.invalid> wrote in message
> > > > news:e%237BQOLYGHA.3448 [at] TK2MSFTNGP04.phx.gbl...
> > > > > Change;
> > > > >
> > > > > sqlStr = "Select * From tblusers where UID = '" _
> > > > > & Request.Form("UID") & "' and PWD = '" & Request.Form("PWD")
&
> > > > > "'"
> > > > >
> > > > > ' Opens the returned values from the SQL as a recordset,
> > > > > ' ready for iteration by ASP
> > > > > '// <<< LINE 53 >>> set rcSet = cnStr.Execute(sqlStr)
> > > > > ' validate variables against database
> > > > > // If (not rcSet.BOF) and (not rcSet.EOF) then
> > > > >
> > > > > '// Check before processing
> > > > > If Len(frmUsername) < 1 Then frmUsername = "NULL"
> > > > > If Len(frmPassword) < 1 Then frmPassword = "NULL"
> > > > >
> > > > > To;
> > > > >
> > > > > '// Check before processing
> > > > > If Len(frmUsername) < 1 Then frmUsername = "NULL"
> > > > > If Len(frmPassword) < 1 Then frmPassword = "NULL"
> > > > > Response.Write "<b><i>DEBUG</i><b><br>Username: " _
> > > > > & frmUID & "<br>Password: " & frmPWD
> > > > > sqlStr = "Select * From tblusers where UID = '" _
> > > > > & frmUID & "' and PWD = '" & frmPWD & "'"
> > > > >
> > > > > ' Opens the returned values from the SQL as a recordset,
> > > > > ' ready for iteration by ASP
> > > > > '// <<< LINE 53 >>> set rcSet = cnStr.Execute(sqlStr)
> > > > > ' validate variables against database
> > > > > // If (not rcSet.BOF) and (not rcSet.EOF) then
> > > > >
> > > > > --
> > > > > Regards
> > > > >
> > > > > Steven Burn
> > > > > Ur I.T. Mate Group
> > > > > www.it-mate.co.uk
> > > > >
> > > > > Keeping it FREE!
> > > > >
> > > > > "malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
> > > > > news:4441284e$0$23185$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
> > > > >> I am now presented with incorrect Username and/or Password. I
have
> > > > >> double
> > > > >> checked this.
> > > > >>
> > > > >> I now have the following code in my page
> > > > >>
> > > > >> <% [at] Language="VBScript"%>
> > > > >>
> > > > >> <!-- METADATA TYPE="typelib" FILE="C:\Program Files\Common
> > > > >> Files\System\ado\msado15.dll" -->
> > > > >> <!-- #include file="Connectionstring.asp" -->
> > > > >> <%
> > > > >> ' /////////////////////////////////////
> > > > >> ' login validation script
> > > > >> ' © Matt Millross
> > > > >> ' www.designplace.org
> > > > >> ' free for use as long as copyright notice left intact
> > > > >> ' For more scripts, visit www.designplace.org
> > > > >> ' /////////////////////////////////////
> > > > >>
> > > > >> ' variables
> > > > >> dim cnStr, rcSet, frmUID, frmPWD, sqlStr
> > > > >>
> > > > >> 'store form input into variables
> > > > >> frmUID = Request.Form("UID")
> > > > >> frmPWD = Request.Form("PWD")
> > > > >>
> > > > >> 'create connection and recordset objects
> > > > >> Set cnStr = Server.CreateObject("ADODB.Connection")
> > > > >> '// THIS IS NOT NEEDED!
> > > > >> '// Set rcSet = Server.CreateObject("ADODB.Recordset")
> > > > >>
> > > > >> ' defining database connection (connectionstring.asp)
> > > > >> cnStr.ConnectionString = path
> > > > >> cnStr.Provider = provider
> > > > >> cnStr.open
> > > > >>
> > > > >> ' execute sql and open as recordset
> > > > >> '// sqlStr = "Select * From tblusers where username = '" _
> > > > >> '// & Request.Form("UID") & "' and password = '" &
> > > > >> Request.Form("PWD")
> > > > >> &
> > > > >> "'"
> > > > >> '// You've already stored the user/pass into a local var - use
> > > > >> them!
> > > > >> '// and NEVER use "Select * ..."
> > > > >> '//
> > > > >> '// http://aspfaq.com/show.asp?id 96
> > > > >>
> > > > >> sqlStr = "Select * From tblusers where UID = '" _
> > > > >> & Request.Form("UID") & "' and PWD = '" &
Request.Form("PWD")
> > > > >> &
> > > > >> "'"
> > > > >>
> > > > >> ' Opens the returned values from the SQL as a recordset,
> > > > >> ' ready for iteration by ASP
> > > > >> '// <<< LINE 53 >>> set rcSet = cnStr.Execute(sqlStr)
> > > > >> ' validate variables against database
> > > > >> // If (not rcSet.BOF) and (not rcSet.EOF) then
> > > > >>
> > > > >> '// Check before processing
> > > > >> If Len(frmUsername) < 1 Then frmUsername = "NULL"
> > > > >> If Len(frmPassword) < 1 Then frmPassword = "NULL"
> > > > >> '// Then go...
> > > > >> Set rcSet = cnStr.Execute(sqlStr)
> > > > >>
> > > > >> If NOT rcSet.EOF Then
> > > > >> response.cookies("validated_user") = frmUID
> > > > >> response.write "<h1>Login successful!</h1>"
> > > > >> '// Forget using rcSet.Fields, and just use rcSet
> > > > >> '// directly
> > > > >> response.write "<p>Welcome " & rcSet(1) & "</p>"
> > > > >> else
> > > > >> response.write "incorrect Username and/or Password"
> > > > >> end if
> > > > >>
> > > > >> '// Don't forget to cleanup after yourself
> > > > >> cnStr.Close: Set cnStr = Nothing
> > > > >> Set rcSet = Nothing
> > > > >> %>
> > > > >>
> > > > >>
> > > > >> Regards
> > > > >> Malcolm
> > > > >>
> > > > >>
> > > > >> "malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
> > > > >> news:4441273b$0$23177$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
> > > > >> > UID and PWD are the 2 fields in my database that hold the
> > > > >> > information.
> > > > >> >
> > > > >> > I have now changed the code
> > > > >> >
> > > > >> > "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
> > > > >> > news:1145119070.271743.314040 [at] z34g2000cwc.googlegroups.com.. .
> > > > >> >>
> > > > >> >> malcolm wrote:
> > > > >> >>> Hi, while trying to validate username and password on login
> > > > >> >>> form
> > > > >> >>> I
> > > > >> >>> am
> > > > >> >>> presented with the following error message
> > > > >> >>>
> > > > >> >>>
> > > > >> >>> Microsoft JET Database Engine error '80040e10'
> > > > >> >>>
> > > > >> >>> No value given for one or more required parameters.
> > > > >> >>>
> > > > >> >>> /vdateUsr.asp, line 53
> > > > >> >>>
> > > > >> >>> The 2 fields within the database are text fields (UID) and
> > > > >> >>> (PWD)
> > > > >> >>> these
> > > > >> >>> are
> > > > >> >>> spelt correctly!
> > > > >> >>>
> > > > >> >>
> > > > >> >> <snip>
> > > > >> >>> sqlStr = "Select * From tblusers where username = '" _
> > > > >> >>> & Request.Form("UID") & "' and password = '" &
> > > > >> >>> Request.Form("PWD")
> > > > > &
> > > > >> >>> "'"
> > > > >> >>>
> > > > >> >>
> > > > >> >> No - they're not spelt correctly. In your SQL statement you
> > > > >> >> refer
> > > > >> >> to
> > > > >> >> two fields called username and password, yet you said they are
> > > > >> >> called
> > > > >> >> UID and PWD. Which is correct?
> > > > >> >>
> > > > >> >> --
> > > > >> >> Mike Brind
> > > > >> >>
> > > > >> >
> > > > >> >
> > > > >>
> > > > >>
> > > > >
> > > > >
>
>
Re: Validate logins with ASP, MS Access and Cookies error
If you still want to redirect them back ot the original page on
successful login, then put this:
Session("UID") =3D Request("UID")
Response.Redirect Session("REFERRER")
in place of response.write "<p>Welcome " & rcSet(0) & "</p>".
--
Mike Brind
malcolm wrote:
> Yes.
> I used that system to do just that Mike... Not sure waht to do now as it
> will not work!
>
>
> Malcolm
>
>
> "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
> news:1145132830.519120.327380 [at] z34g2000cwc.googlegroups.com.. .
> You would only have to put [ ] brackets around the field name if you
> are using a reserved word, or have an embedded space in the field name.
> If "prefered_name" is the new name for that field, you can leave the
> brackets off.
>
> Wrt the new bit of code you just posted, what do you want it to
> actually do? It looks to me as if that was part of a system where
> people filled out a form on one page, it posted to another for
> processing, then if the login was successful, it sent them back to the
> first page again. Is that right? And if so, is that what you still
> want to happen?
>
> --
> Mike Brind
>
>
>
> malcolm wrote:
> > Thanks Mike,
> >
> > So if I change my code it would look like this
> >
> >
> >
> > "Select [prefered_name], UID From tblusers where UID =3D '" _
> >
> > & Request.Form("UID") & "' and PWD =3D '" & Request.Form("PWD")=
&
> > "'"
> >
> >
> >
> > The problem I now find with this code is the fact that my old code work=
ed
> > really well and would re-direct users to the referrer page?? How can I =
do
> > that with this code??
> >
> >
> >
> > The code used in my old page was
> >
> >
> >
> > <% [at] language=3D"vbscript" %>
> >
> >
> >
> > <%
> >
> > ' Was this page posted to?
> >
> > If UCase(Request.ServerVariables("HTTP_METHOD")) =3D "POST" Then
> >
> > ' If so, check the username/password that was entered.
> >
> > If ComparePassword(Request("UID"),Request("PWD")) Then
> >
> > ' If comparison was good, store the user name...
> >
> > Session("UID") =3D Request("UID")
> >
> > ' ...and redirect back to the original page.
> >
> > Response.Redirect Session("REFERRER")
> >
> > End If
> >
> > End If
> >
> > %>
> >
> >
> >
> > Regards
> >
> > Malcolm
> >
> >
> > "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
> > news:1145127899.468752.169210 [at] e56g2000cwe.googlegroups.com.. .
> > Bad choice of field name. "Name" a reserved word in Access. Steve
> > Burns posted the correct answer to your question, but it would have
> > thrown up an error in this case.
> >
> > Change it if you can, but if not, your sqlStr will have to look like
> > this:
> >
> > "Select [name], UID From tblusers where UID =3D '"
> > _ & Request.Form("UID") & "' and PWD =3D '" & Request.Form("PWD") & "'"
> >
> > Even then, there are other problems with the approach you are taking.
> > If you copy and paste the following line into the user name and
> > password fields in your form:
> >
> > ' or ''=3D'
> >
> > You will always log in successfully. This is a common SQL Injection
> > attack method. Also, if you have someone who's username contains an
> > apostophe, you will get errors. The best defence against this is to
> > use a saved parameter query in your Access database:
> >
> > http://www.xefteri.com/articles/show.cfm?id=3D6
> >
> > --
> > Mike Brind
> >
> >
> > malcolm wrote:
> > > Name is the name of the field and the database is MS access.
> > >
> > >
> > >
> > > "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
> > > news:1145125091.697554.101780 [at] v46g2000cwv.googlegroups.com.. .
> > > Which field in the database holds the user's first name? And what ty=
pe
> > > of database are you using?
> > >
> > > --
> > > Mike Brind
> > >
> > >
> > > malcolm wrote:
> > > > Thanks Guys, i have now cleaned up the code and it is working ok. J=
ust
> > > > one
> > > > thing I want to ask! on the login successful page it shows the
> > > > username
> > > > aas
> > > > typed into the form UID field.. what I would like to do now is actu=
lly
> > > > return another column from the database that stores the users 1st n=
ame
> > > > :-)
> > > >
> > > > any tips
> > > >
> > > > here is the code I am using now. :-)
> > > >
> > > > <% [at] Language=3D"VBScript"%>
> > > >
> > > > <!-- METADATA TYPE=3D"typelib" FILE=3D"C:\Program Files\Common
> > > > Files\System\ado\msado15.dll" -->
> > > > <!-- #include file=3D"Connectionstring.asp" -->
> > > > <%
> > > >
> > > > ' variables
> > > > dim cnStr, rcSet, frmUID, frmPWD, sqlStr
> > > >
> > > > 'store form input into variables
> > > > frmUID =3D Request.Form("UID")
> > > > frmPWD =3D Request.Form("PWD")
> > > >
> > > > 'create connection and recordset objects
> > > > Set cnStr =3D Server.CreateObject("ADODB.Connection")
> > > >
> > > > ' defining database connection (connectionstring.asp)
> > > > cnStr.ConnectionString =3D path
> > > > cnStr.Provider =3D provider
> > > > cnStr.open
> > > >
> > > > ' execute sql and open as recordset
> > > >
> > > > sqlStr =3D "Select * From tblusers where UID =3D '" _
> > > > & Request.Form("UID") & "' and PWD =3D '" & Request.Form("PWD"=
) &
> > > > "'"
> > > >
> > > > ' Opens the returned values from the SQL as a recordset,
> > > > ' ready for iteration by ASP
> > > > ' validate variables against database
> > > > // If (not rcSet.BOF) and (not rcSet.EOF) then
> > > >
> > > > If Len(frmUID) < 1 Then frmUID =3D "NULL"
> > > > If Len(frmPWD) < 1 Then frmPWD =3D "NULL"
> > > >
> > > > Set rcSet =3D cnStr.Execute(sqlStr)
> > > >
> > > > If NOT rcSet.EOF Then
> > > > response.cookies("validated_user") =3D frmUID
> > > > response.write "<h1>Login successful!</h1>"
> > > >
> > > > response.write "<p>Welcome " & rcSet(0) & "</p>"
> > > > else
> > > > response.write "Incorrect Username and/or Password"
> > > > end if
> > > >
> > > > cnStr.Close: Set cnStr =3D Nothing
> > > > Set rcSet =3D Nothing
> > > > %>
> > > >
> > > > I had to change this code
> > > > response.write "<p>Welcome " & rcSet(1) & "</p>"
> > > > to this code
> > > > response.write "<p>Welcome " & rcSet(0) & "</p>"
> > > > so that it would display the username and not the password ;-)
> > > > not bad for a guess. :-)
> > > >
> > > > Regards
> > > > Malcolm
> > > >
> > > >
> > > > "Steven Burn" <somewhere [at] in-time.invalid> wrote in message
> > > > news:e%237BQOLYGHA.3448 [at] TK2MSFTNGP04.phx.gbl...
> > > > > Change;
> > > > >
> > > > > sqlStr =3D "Select * From tblusers where UID =3D '" _
> > > > > & Request.Form("UID") & "' and PWD =3D '" & Request.Form("PWD=
") &
> > > > > "'"
> > > > >
> > > > > ' Opens the returned values from the SQL as a recordset,
> > > > > ' ready for iteration by ASP
> > > > > '// <<< LINE 53 >>> set rcSet =3D cnStr.Execute(sqlStr)
> > > > > ' validate variables against database
> > > > > // If (not rcSet.BOF) and (not rcSet.EOF) then
> > > > >
> > > > > '// Check before processing
> > > > > If Len(frmUsername) < 1 Then frmUsername =3D "NULL"
> > > > > If Len(frmPassword) < 1 Then frmPassword =3D "NULL"
> > > > >
> > > > > To;
> > > > >
> > > > > '// Check before processing
> > > > > If Len(frmUsername) < 1 Then frmUsername =3D "NULL"
> > > > > If Len(frmPassword) < 1 Then frmPassword =3D "NULL"
> > > > > Response.Write "<b><i>DEBUG</i><b><br>Username: " _
> > > > > & frmUID & "<br>Password: " & frmPWD
> > > > > sqlStr =3D "Select * From tblusers where UID =3D '" _
> > > > > & frmUID & "' and PWD =3D '" & frmPWD & "'"
> > > > >
> > > > > ' Opens the returned values from the SQL as a recordset,
> > > > > ' ready for iteration by ASP
> > > > > '// <<< LINE 53 >>> set rcSet =3D cnStr.Execute(sqlStr)
> > > > > ' validate variables against database
> > > > > // If (not rcSet.BOF) and (not rcSet.EOF) then
> > > > >
> > > > > --
> > > > > Regards
> > > > >
> > > > > Steven Burn
> > > > > Ur I.T. Mate Group
> > > > > www.it-mate.co.uk
> > > > >
> > > > > Keeping it FREE!
> > > > >
> > > > > "malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
> > > > > news:4441284e$0$23185$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
> > > > >> I am now presented with incorrect Username and/or Password. I ha=
ve
> > > > >> double
> > > > >> checked this.
> > > > >>
> > > > >> I now have the following code in my page
> > > > >>
> > > > >> <% [at] Language=3D"VBScript"%>
> > > > >>
> > > > >> <!-- METADATA TYPE=3D"typelib" FILE=3D"C:\Program Files\Common
> > > > >> Files\System\ado\msado15.dll" -->
> > > > >> <!-- #include file=3D"Connectionstring.asp" -->
> > > > >> <%
> > > > >> ' /////////////////////////////////////
> > > > >> ' login validation script
> > > > >> ' =A9 Matt Millross
> > > > >> ' www.designplace.org
> > > > >> ' free for use as long as copyright notice left intact
> > > > >> ' For more scripts, visit www.designplace.org
> > > > >> ' /////////////////////////////////////
> > > > >>
> > > > >> ' variables
> > > > >> dim cnStr, rcSet, frmUID, frmPWD, sqlStr
> > > > >>
> > > > >> 'store form input into variables
> > > > >> frmUID =3D Request.Form("UID")
> > > > >> frmPWD =3D Request.Form("PWD")
> > > > >>
> > > > >> 'create connection and recordset objects
> > > > >> Set cnStr =3D Server.CreateObject("ADODB.Connection")
> > > > >> '// THIS IS NOT NEEDED!
> > > > >> '// Set rcSet =3D Server.CreateObject("ADODB.Recordset")
> > > > >>
> > > > >> ' defining database connection (connectionstring.asp)
> > > > >> cnStr.ConnectionString =3D path
> > > > >> cnStr.Provider =3D provider
> > > > >> cnStr.open
> > > > >>
> > > > >> ' execute sql and open as recordset
> > > > >> '// sqlStr =3D "Select * From tblusers where username =3D '" _
> > > > >> '// & Request.Form("UID") & "' and password =3D '" &
> > > > >> Request.Form("PWD")
> > > > >> &
> > > > >> "'"
> > > > >> '// You've already stored the user/pass into a local var - use
> > > > >> them!
> > > > >> '// and NEVER use "Select * ..."
> > > > >> '//
> > > > >> '// http://aspfaq.com/show.asp?id=3D2096
> > > > >>
> > > > >> sqlStr =3D "Select * From tblusers where UID =3D '" _
> > > > >> & Request.Form("UID") & "' and PWD =3D '" & Request.Form("P=
WD")
> > > > >> &
> > > > >> "'"
> > > > >>
> > > > >> ' Opens the returned values from the SQL as a recordset,
> > > > >> ' ready for iteration by ASP
> > > > >> '// <<< LINE 53 >>> set rcSet =3D cnStr.Execute(sqlStr)
> > > > >> ' validate variables against database
> > > > >> // If (not rcSet.BOF) and (not rcSet.EOF) then
> > > > >>
> > > > >> '// Check before processing
> > > > >> If Len(frmUsername) < 1 Then frmUsername =3D "NULL"
> > > > >> If Len(frmPassword) < 1 Then frmPassword =3D "NULL"
> > > > >> '// Then go...
> > > > >> Set rcSet =3D cnStr.Execute(sqlStr)
> > > > >>
> > > > >> If NOT rcSet.EOF Then
> > > > >> response.cookies("validated_user") =3D frmUID
> > > > >> response.write "<h1>Login successful!</h1>"
> > > > >> '// Forget using rcSet.Fields, and just use rcSet
> > > > >> '// directly
> > > > >> response.write "<p>Welcome " & rcSet(1) & "</p>"
> > > > >> else
> > > > >> response.write "incorrect Username and/or Password"
> > > > >> end if
> > > > >>
> > > > >> '// Don't forget to cleanup after yourself
> > > > >> cnStr.Close: Set cnStr =3D Nothing
> > > > >> Set rcSet =3D Nothing
> > > > >> %>
> > > > >>
> > > > >>
> > > > >> Regards
> > > > >> Malcolm
> > > > >>
> > > > >>
> > > > >> "malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
> > > > >> news:4441273b$0$23177$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
> > > > >> > UID and PWD are the 2 fields in my database that hold the
> > > > >> > information.
> > > > >> >
> > > > >> > I have now changed the code
> > > > >> >
> > > > >> > "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
> > > > >> > news:1145119070.271743.314040 [at] z34g2000cwc.googlegroups.com.. .
> > > > >> >>
> > > > >> >> malcolm wrote:
> > > > >> >>> Hi, while trying to validate username and password on login
> > > > >> >>> form
> > > > >> >>> I
> > > > >> >>> am
> > > > >> >>> presented with the following error message
> > > > >> >>>
> > > > >> >>>
> > > > >> >>> Microsoft JET Database Engine error '80040e10'
> > > > >> >>>
> > > > >> >>> No value given for one or more required parameters.
> > > > >> >>>
> > > > >> >>> /vdateUsr.asp, line 53
> > > > >> >>>
> > > > >> >>> The 2 fields within the database are text fields (UID) and
> > > > >> >>> (PWD)
> > > > >> >>> these
> > > > >> >>> are
> > > > >> >>> spelt correctly!
> > > > >> >>>
> > > > >> >>
> > > > >> >> <snip>
> > > > >> >>> sqlStr =3D "Select * From tblusers where username =3D '" _
> > > > >> >>> & Request.Form("UID") & "' and password =3D '" &
> > > > >> >>> Request.Form("PWD")
> > > > > &
> > > > >> >>> "'"
> > > > >> >>>
> > > > >> >>
> > > > >> >> No - they're not spelt correctly. In your SQL statement you
> > > > >> >> refer
> > > > >> >> to
> > > > >> >> two fields called username and password, yet you said they are
> > > > >> >> called
> > > > >> >> UID and PWD. Which is correct?
> > > > >> >>
> > > > >> >> --
> > > > >> >> Mike Brind
> > > > >> >>
> > > > >> >
> > > > >> >
> > > > >>
> > > > >>
> > > > >
> > > > >
Re: Validate logins with ASP, MS Access and Cookies error
Steven Burn wrote:
> Woot!, another PN customer <g>
>
PN? What's that then?
--
Mike Brind
Re: Validate logins with ASP, MS Access and Cookies error
hehe, PlusNet ;o)
--
Regards
Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk
Keeping it FREE!
"Mike Brind" <paxtonend [at] hotmail.com> wrote in message
news:1145135351.337275.53400 [at] u72g2000cwu.googlegroups.com...
>
> Steven Burn wrote:
> > Woot!, another PN customer <g>
> >
>
> PN? What's that then?
>
> --
> Mike Brind
>
Re: Validate logins with ASP, MS Access and Cookies error
Oh, I thought maybe it was the name of the some free code that the op
had been using, and that you had recognised it. Had a look at PlusNet
web site. How utterly, utterly horrible. Potential customers would
have to be desperate to wait for each page to unpeel like that.
--
Mike Brind
Steven Burn wrote:
> hehe, PlusNet ;o)
>
> --
> Regards
>
> Steven Burn
> Ur I.T. Mate Group
> www.it-mate.co.uk
>
> Keeping it FREE!
>
> "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
> news:1145135351.337275.53400 [at] u72g2000cwu.googlegroups.com...
> >
> > Steven Burn wrote:
> > > Woot!, another PN customer <g>
> > >
> >
> > PN? What's that then?
> >
> > --
> > Mike Brind
> >
Re: Validate logins with ASP, MS Access and Cookies error
Rofl, the website is only the half of it <g>
--
Regards
Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk
Keeping it FREE!
"Mike Brind" <paxtonend [at] hotmail.com> wrote in message
news:1145216119.201139.171120 [at] t31g2000cwb.googlegroups.com.. .
> Oh, I thought maybe it was the name of the some free code that the op
> had been using, and that you had recognised it. Had a look at PlusNet
> web site. How utterly, utterly horrible. Potential customers would
> have to be desperate to wait for each page to unpeel like that.
>
> --
> Mike Brind
>
> Steven Burn wrote:
> > hehe, PlusNet ;o)
> >
> > --
> > Regards
> >
> > Steven Burn
> > Ur I.T. Mate Group
> > www.it-mate.co.uk
> >
> > Keeping it FREE!
> >
> > "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
> > news:1145135351.337275.53400 [at] u72g2000cwu.googlegroups.com...
> > >
> > > Steven Burn wrote:
> > > > Woot!, another PN customer <g>
> > > >
> > >
> > > PN? What's that then?
> > >
> > > --
> > > Mike Brind
> > >
>
Re: Validate logins with ASP, MS Access and Cookies error
I do follow articles like those found on these websites.
when it goes wrong I am stuck and need to speak to guys like you 2.
What good books can you recommend ? I am obviously interested in ASP and
basic scripts.
Regards
Malcolm
www.bankchargesrefunded.co.uk
"Mike Brind" <paxtonend [at] hotmail.com> wrote in message
news:1145131736.516317.252350 [at] z34g2000cwc.googlegroups.com.. .
Steve was pointing out that SELECT *(asterisk) is a BAD thing. SELECT
* returns all the rows in the tables in your FROM clause. When we
changed the SELECT statement to SELECT [name], UID FROM... it got round
the SELECT * problem.
If you plan to do much more ASP, I would advise looking for tutorials
that explain the code they offer, rather than these kinds of free
scripts. There are some excellent sites around, including
www.asp101.com and www.learnasp.com.
Another way to learn stuff is to make mistakes, and copy and paste the
error messages into www.aspfaq.com.
Good luck
--
Mike Brind
malcolm wrote:
> I have now changed the code which Mike advised and it now works.
>
> I have no idea how to do that Steven! I did read the article that you
> refer
> me too.
>
> I have not stopped using "Select" because I don't know what to replace it
> with!! I have gone back over the trail and found this
>
> '// and NEVER use "Select * ..."
>
> '//
>
> '// http://aspfaq.com/show.asp?id 96
>
>
>
> I read that article. 2096 1st time but not sure how to implement the
> changes
> you recommend ?
>
>
>
>
>
> Regards
>
> Malcolm
>
>
>
>
>
> "Steven Burn" <somewhere [at] in-time.invalid> wrote in message
> news:edTpQvLYGHA.4484 [at] TK2MSFTNGP02.phx.gbl...
> > AGAIN, stop using "Select *" !!!!!!
> >
> > http://aspfaq.com/show.asp?id 96
> >
> > As for returning the users actual name, just select it from the DB;
> >
> > strSQL = "Select UsersName, UID From tblUsers Where UID = '" & strUID &
> > "'"
> >
> > Where "UsersName" is the name of the field that holds the data you
> > require.
> >
> > --
> > Regards
> >
> > Steven Burn
> > Ur I.T. Mate Group
> > www.it-mate.co.uk
> >
> > Keeping it FREE!
> >
> > "malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
> > news:444133fc$0$23199$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
> >> Thanks Guys, i have now cleaned up the code and it is working ok. Just
> >> one
> >> thing I want to ask! on the login successful page it shows the username
> > aas
> >> typed into the form UID field.. what I would like to do now is actully
> >> return another column from the database that stores the users 1st name
> >> :-)
> >>
> >> any tips
> >>
> >> here is the code I am using now. :-)
> >>
> >> <% [at] Language="VBScript"%>
> >>
> >> <!-- METADATA TYPE="typelib" FILE="C:\Program Files\Common
> >> Files\System\ado\msado15.dll" -->
> >> <!-- #include file="Connectionstring.asp" -->
> >> <%
> >>
> >> ' variables
> >> dim cnStr, rcSet, frmUID, frmPWD, sqlStr
> >>
> >> 'store form input into variables
> >> frmUID = Request.Form("UID")
> >> frmPWD = Request.Form("PWD")
> >>
> >> 'create connection and recordset objects
> >> Set cnStr = Server.CreateObject("ADODB.Connection")
> >>
> >> ' defining database connection (connectionstring.asp)
> >> cnStr.ConnectionString = path
> >> cnStr.Provider = provider
> >> cnStr.open
> >>
> >> ' execute sql and open as recordset
> >>
> >> sqlStr = "Select * From tblusers where UID = '" _
> >> & Request.Form("UID") & "' and PWD = '" & Request.Form("PWD") &
> >> "'"
> >>
> >> ' Opens the returned values from the SQL as a recordset,
> >> ' ready for iteration by ASP
> >> ' validate variables against database
> >> // If (not rcSet.BOF) and (not rcSet.EOF) then
> >>
> >> If Len(frmUID) < 1 Then frmUID = "NULL"
> >> If Len(frmPWD) < 1 Then frmPWD = "NULL"
> >>
> >> Set rcSet = cnStr.Execute(sqlStr)
> >>
> >> If NOT rcSet.EOF Then
> >> response.cookies("validated_user") = frmUID
> >> response.write "<h1>Login successful!</h1>"
> >>
> >> response.write "<p>Welcome " & rcSet(0) & "</p>"
> >> else
> >> response.write "Incorrect Username and/or Password"
> >> end if
> >>
> >> cnStr.Close: Set cnStr = Nothing
> >> Set rcSet = Nothing
> >> %>
> >>
> >> I had to change this code
> >> response.write "<p>Welcome " & rcSet(1) & "</p>"
> >> to this code
> >> response.write "<p>Welcome " & rcSet(0) & "</p>"
> >> so that it would display the username and not the password ;-)
> >> not bad for a guess. :-)
> >>
> >> Regards
> >> Malcolm
> >>
> >>
> >> "Steven Burn" <somewhere [at] in-time.invalid> wrote in message
> >> news:e%237BQOLYGHA.3448 [at] TK2MSFTNGP04.phx.gbl...
> >> > Change;
> >> >
> >> > sqlStr = "Select * From tblusers where UID = '" _
> >> > & Request.Form("UID") & "' and PWD = '" & Request.Form("PWD") &
> >> > "'"
> >> >
> >> > ' Opens the returned values from the SQL as a recordset,
> >> > ' ready for iteration by ASP
> >> > '// <<< LINE 53 >>> set rcSet = cnStr.Execute(sqlStr)
> >> > ' validate variables against database
> >> > // If (not rcSet.BOF) and (not rcSet.EOF) then
> >> >
> >> > '// Check before processing
> >> > If Len(frmUsername) < 1 Then frmUsername = "NULL"
> >> > If Len(frmPassword) < 1 Then frmPassword = "NULL"
> >> >
> >> > To;
> >> >
> >> > '// Check before processing
> >> > If Len(frmUsername) < 1 Then frmUsername = "NULL"
> >> > If Len(frmPassword) < 1 Then frmPassword = "NULL"
> >> > Response.Write "<b><i>DEBUG</i><b><br>Username: " _
> >> > & frmUID & "<br>Password: " & frmPWD
> >> > sqlStr = "Select * From tblusers where UID = '" _
> >> > & frmUID & "' and PWD = '" & frmPWD & "'"
> >> >
> >> > ' Opens the returned values from the SQL as a recordset,
> >> > ' ready for iteration by ASP
> >> > '// <<< LINE 53 >>> set rcSet = cnStr.Execute(sqlStr)
> >> > ' validate variables against database
> >> > // If (not rcSet.BOF) and (not rcSet.EOF) then
> >> >
> >> > --
> >> > Regards
> >> >
> >> > Steven Burn
> >> > Ur I.T. Mate Group
> >> > www.it-mate.co.uk
> >> >
> >> > Keeping it FREE!
> >> >
> >> > "malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
> >> > news:4441284e$0$23185$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
> >> >> I am now presented with incorrect Username and/or Password. I have
> > double
> >> >> checked this.
> >> >>
> >> >> I now have the following code in my page
> >> >>
> >> >> <% [at] Language="VBScript"%>
> >> >>
> >> >> <!-- METADATA TYPE="typelib" FILE="C:\Program Files\Common
> >> >> Files\System\ado\msado15.dll" -->
> >> >> <!-- #include file="Connectionstring.asp" -->
> >> >> <%
> >> >> ' /////////////////////////////////////
> >> >> ' login validation script
> >> >> ' © Matt Millross
> >> >> ' www.designplace.org
> >> >> ' free for use as long as copyright notice left intact
> >> >> ' For more scripts, visit www.designplace.org
> >> >> ' /////////////////////////////////////
> >> >>
> >> >> ' variables
> >> >> dim cnStr, rcSet, frmUID, frmPWD, sqlStr
> >> >>
> >> >> 'store form input into variables
> >> >> frmUID = Request.Form("UID")
> >> >> frmPWD = Request.Form("PWD")
> >> >>
> >> >> 'create connection and recordset objects
> >> >> Set cnStr = Server.CreateObject("ADODB.Connection")
> >> >> '// THIS IS NOT NEEDED!
> >> >> '// Set rcSet = Server.CreateObject("ADODB.Recordset")
> >> >>
> >> >> ' defining database connection (connectionstring.asp)
> >> >> cnStr.ConnectionString = path
> >> >> cnStr.Provider = provider
> >> >> cnStr.open
> >> >>
> >> >> ' execute sql and open as recordset
> >> >> '// sqlStr = "Select * From tblusers where username = '" _
> >> >> '// & Request.Form("UID") & "' and password = '" &
> > Request.Form("PWD")
> >> >> &
> >> >> "'"
> >> >> '// You've already stored the user/pass into a local var - use them!
> >> >> '// and NEVER use "Select * ..."
> >> >> '//
> >> >> '// http://aspfaq.com/show.asp?id 96
> >> >>
> >> >> sqlStr = "Select * From tblusers where UID = '" _
> >> >> & Request.Form("UID") & "' and PWD = '" & Request.Form("PWD") &
> > "'"
> >> >>
> >> >> ' Opens the returned values from the SQL as a recordset,
> >> >> ' ready for iteration by ASP
> >> >> '// <<< LINE 53 >>> set rcSet = cnStr.Execute(sqlStr)
> >> >> ' validate variables against database
> >> >> // If (not rcSet.BOF) and (not rcSet.EOF) then
> >> >>
> >> >> '// Check before processing
> >> >> If Len(frmUsername) < 1 Then frmUsername = "NULL"
> >> >> If Len(frmPassword) < 1 Then frmPassword = "NULL"
> >> >> '// Then go...
> >> >> Set rcSet = cnStr.Execute(sqlStr)
> >> >>
> >> >> If NOT rcSet.EOF Then
> >> >> response.cookies("validated_user") = frmUID
> >> >> response.write "<h1>Login successful!</h1>"
> >> >> '// Forget using rcSet.Fields, and just use rcSet
> >> >> '// directly
> >> >> response.write "<p>Welcome " & rcSet(1) & "</p>"
> >> >> else
> >> >> response.write "incorrect Username and/or Password"
> >> >> end if
> >> >>
> >> >> '// Don't forget to cleanup after yourself
> >> >> cnStr.Close: Set cnStr = Nothing
> >> >> Set rcSet = Nothing
> >> >> %>
> >> >>
> >> >>
> >> >> Regards
> >> >> Malcolm
> >> >>
> >> >>
> >> >> "malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
> >> >> news:4441273b$0$23177$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
> >> >> > UID and PWD are the 2 fields in my database that hold the
> > information.
> >> >> >
> >> >> > I have now changed the code
> >> >> >
> >> >> > "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
> >> >> > news:1145119070.271743.314040 [at] z34g2000cwc.googlegroups.com.. .
> >> >> >>
> >> >> >> malcolm wrote:
> >> >> >>> Hi, while trying to validate username and password on login form
> >> >> >>> I
> > am
> >> >> >>> presented with the following error message
> >> >> >>>
> >> >> >>>
> >> >> >>> Microsoft JET Database Engine error '80040e10'
> >> >> >>>
> >> >> >>> No value given for one or more required parameters.
> >> >> >>>
> >> >> >>> /vdateUsr.asp, line 53
> >> >> >>>
> >> >> >>> The 2 fields within the database are text fields (UID) and (PWD)
> >> >> >>> these
> >> >> >>> are
> >> >> >>> spelt correctly!
> >> >> >>>
> >> >> >>
> >> >> >> <snip>
> >> >> >>> sqlStr = "Select * From tblusers where username = '" _
> >> >> >>> & Request.Form("UID") & "' and password = '" &
> > Request.Form("PWD")
> >> > &
> >> >> >>> "'"
> >> >> >>>
> >> >> >>
> >> >> >> No - they're not spelt correctly. In your SQL statement you
> >> >> >> refer
> > to
> >> >> >> two fields called username and password, yet you said they are
> > called
> >> >> >> UID and PWD. Which is correct?
> >> >> >>
> >> >> >> --
> >> >> >> Mike Brind
> >> >> >>
> >> >> >
> >> >> >
> >> >>
> >> >>
> >> >
> >> >
> >>
> >>
> >
> >
Re: Validate logins with ASP, MS Access and Cookies error
It is even better in FireFox...
http://69.51.91.77/workbench/images/Untitled-1.gif
Bob Lehmann
"Mike Brind" <paxtonend [at] hotmail.com> wrote in message
news:1145216119.201139.171120 [at] t31g2000cwb.googlegroups.com.. .
> Oh, I thought maybe it was the name of the some free code that the op
> had been using, and that you had recognised it. Had a look at PlusNet
> web site. How utterly, utterly horrible. Potential customers would
> have to be desperate to wait for each page to unpeel like that.
>
> --
> Mike Brind
>
> Steven Burn wrote:
> > hehe, PlusNet ;o)
> >
> > --
> > Regards
> >
> > Steven Burn
> > Ur I.T. Mate Group
> > www.it-mate.co.uk
> >
> > Keeping it FREE!
> >
> > "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
> > news:1145135351.337275.53400 [at] u72g2000cwu.googlegroups.com...
> > >
> > > Steven Burn wrote:
> > > > Woot!, another PN customer <g>
> > > >
> > >
> > > PN? What's that then?
> > >
> > > --
> > > Mike Brind
> > >
>
Re: Validate logins with ASP, MS Access and Cookies error
Excuse me for being a bit dim! but what the hell is that picture and why all
the bad mouth over plusnet ?
you guys wana let me in on the secret here?
my msn messenger handle is malcolmk [at] fsmail.net
cheers
mal
"Bob Lehmann" <nospam [at] dontbotherme.zzz> wrote in message
news:ORxWjoZYGHA.3328 [at] TK2MSFTNGP02.phx.gbl...
> It is even better in FireFox...
> http://69.51.91.77/workbench/images/Untitled-1.gif
>
> Bob Lehmann
>
> "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
> news:1145216119.201139.171120 [at] t31g2000cwb.googlegroups.com.. .
>> Oh, I thought maybe it was the name of the some free code that the op
>> had been using, and that you had recognised it. Had a look at PlusNet
>> web site. How utterly, utterly horrible. Potential customers would
>> have to be desperate to wait for each page to unpeel like that.
>>
>> --
>> Mike Brind
>>
>> Steven Burn wrote:
>> > hehe, PlusNet ;o)
>> >
>> > --
>> > Regards
>> >
>> > Steven Burn
>> > Ur I.T. Mate Group
>> > www.it-mate.co.uk
>> >
>> > Keeping it FREE!
>> >
>> > "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
>> > news:1145135351.337275.53400 [at] u72g2000cwu.googlegroups.com...
>> > >
>> > > Steven Burn wrote:
>> > > > Woot!, another PN customer <g>
>> > > >
>> > >
>> > > PN? What's that then?
>> > >
>> > > --
>> > > Mike Brind
>> > >
>>
>
>
Re: Validate logins with ASP, MS Access and Cookies error
Are you going on about http://www.plus.net/
or are you going on about
http://plusnet.com/
where did the image come from
http://69.51.91.77/workbench/images/Untitled-1.gif ????
"Steven Burn" <somewhere [at] in-time.invalid> wrote in message
news:ef7wFBZYGHA.4168 [at] TK2MSFTNGP05.phx.gbl...
> Rofl, the website is only the half of it <g>
>
> --
> Regards
>
> Steven Burn
> Ur I.T. Mate Group
> www.it-mate.co.uk
>
> Keeping it FREE!
>
> "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
> news:1145216119.201139.171120 [at] t31g2000cwb.googlegroups.com.. .
>> Oh, I thought maybe it was the name of the some free code that the op
>> had been using, and that you had recognised it. Had a look at PlusNet
>> web site. How utterly, utterly horrible. Potential customers would
>> have to be desperate to wait for each page to unpeel like that.
>>
>> --
>> Mike Brind
>>
>> Steven Burn wrote:
>> > hehe, PlusNet ;o)
>> >
>> > --
>> > Regards
>> >
>> > Steven Burn
>> > Ur I.T. Mate Group
>> > www.it-mate.co.uk
>> >
>> > Keeping it FREE!
>> >
>> > "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
>> > news:1145135351.337275.53400 [at] u72g2000cwu.googlegroups.com...
>> > >
>> > > Steven Burn wrote:
>> > > > Woot!, another PN customer <g>
>> > > >
>> > >
>> > > PN? What's that then?
>> > >
>> > > --
>> > > Mike Brind
>> > >
>>
>
>
Re: Validate logins with ASP, MS Access and Cookies error
plus.net ;o)
--
Regards
Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk
Keeping it FREE!
"malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
news:4442b913$0$23166$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
> Are you going on about http://www.plus.net/
> or are you going on about
> http://plusnet.com/
>
> where did the image come from
> http://69.51.91.77/workbench/images/Untitled-1.gif ????
>
>
>
> "Steven Burn" <somewhere [at] in-time.invalid> wrote in message
> news:ef7wFBZYGHA.4168 [at] TK2MSFTNGP05.phx.gbl...
> > Rofl, the website is only the half of it <g>
> >
> > --
> > Regards
> >
> > Steven Burn
> > Ur I.T. Mate Group
> > www.it-mate.co.uk
> >
> > Keeping it FREE!
> >
> > "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
> > news:1145216119.201139.171120 [at] t31g2000cwb.googlegroups.com.. .
> >> Oh, I thought maybe it was the name of the some free code that the op
> >> had been using, and that you had recognised it. Had a look at PlusNet
> >> web site. How utterly, utterly horrible. Potential customers would
> >> have to be desperate to wait for each page to unpeel like that.
> >>
> >> --
> >> Mike Brind
> >>
> >> Steven Burn wrote:
> >> > hehe, PlusNet ;o)
> >> >
> >> > --
> >> > Regards
> >> >
> >> > Steven Burn
> >> > Ur I.T. Mate Group
> >> > www.it-mate.co.uk
> >> >
> >> > Keeping it FREE!
> >> >
> >> > "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
> >> > news:1145135351.337275.53400 [at] u72g2000cwu.googlegroups.com...
> >> > >
> >> > > Steven Burn wrote:
> >> > > > Woot!, another PN customer <g>
> >> > > >
> >> > >
> >> > > PN? What's that then?
> >> > >
> >> > > --
> >> > > Mike Brind
> >> > >
> >>
> >
> >
>
>
Re: Validate logins with ASP, MS Access and Cookies error
Hop on over to their forums (my nick over there is MysteryFCM) for an idea
;o)
--
Regards
Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk
Keeping it FREE!
"malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
news:4442b589$0$2567$ed2619ec [at] ptn-nntp-reader02.plus.net...
> Excuse me for being a bit dim! but what the hell is that picture and why
all
> the bad mouth over plusnet ?
>
> you guys wana let me in on the secret here?
>
> my msn messenger handle is malcolmk [at] fsmail.net
>
> cheers
> mal
>
>
>
> "Bob Lehmann" <nospam [at] dontbotherme.zzz> wrote in message
> news:ORxWjoZYGHA.3328 [at] TK2MSFTNGP02.phx.gbl...
> > It is even better in FireFox...
> > http://69.51.91.77/workbench/images/Untitled-1.gif
> >
> > Bob Lehmann
> >
> > "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
> > news:1145216119.201139.171120 [at] t31g2000cwb.googlegroups.com.. .
> >> Oh, I thought maybe it was the name of the some free code that the op
> >> had been using, and that you had recognised it. Had a look at PlusNet
> >> web site. How utterly, utterly horrible. Potential customers would
> >> have to be desperate to wait for each page to unpeel like that.
> >>
> >> --
> >> Mike Brind
> >>
> >> Steven Burn wrote:
> >> > hehe, PlusNet ;o)
> >> >
> >> > --
> >> > Regards
> >> >
> >> > Steven Burn
> >> > Ur I.T. Mate Group
> >> > www.it-mate.co.uk
> >> >
> >> > Keeping it FREE!
> >> >
> >> > "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
> >> > news:1145135351.337275.53400 [at] u72g2000cwu.googlegroups.com...
> >> > >
> >> > > Steven Burn wrote:
> >> > > > Woot!, another PN customer <g>
> >> > > >
> >> > >
> >> > > PN? What's that then?
> >> > >
> >> > > --
> >> > > Mike Brind
> >> > >
> >>
> >
> >
>
>
Re: Validate logins with ASP, MS Access and Cookies error
whats the url ?
"Steven Burn" <somewhere [at] in-time.invalid> wrote in message
news:Oas3WQaYGHA.4996 [at] TK2MSFTNGP03.phx.gbl...
> Hop on over to their forums (my nick over there is MysteryFCM) for an idea
> ;o)
>
> --
> Regards
>
> Steven Burn
> Ur I.T. Mate Group
> www.it-mate.co.uk
>
> Keeping it FREE!
>
> "malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
> news:4442b589$0$2567$ed2619ec [at] ptn-nntp-reader02.plus.net...
>> Excuse me for being a bit dim! but what the hell is that picture and why
> all
>> the bad mouth over plusnet ?
>>
>> you guys wana let me in on the secret here?
>>
>> my msn messenger handle is malcolmk [at] fsmail.net
>>
>> cheers
>> mal
>>
>>
>>
>> "Bob Lehmann" <nospam [at] dontbotherme.zzz> wrote in message
>> news:ORxWjoZYGHA.3328 [at] TK2MSFTNGP02.phx.gbl...
>> > It is even better in FireFox...
>> > http://69.51.91.77/workbench/images/Untitled-1.gif
>> >
>> > Bob Lehmann
>> >
>> > "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
>> > news:1145216119.201139.171120 [at] t31g2000cwb.googlegroups.com.. .
>> >> Oh, I thought maybe it was the name of the some free code that the op
>> >> had been using, and that you had recognised it. Had a look at PlusNet
>> >> web site. How utterly, utterly horrible. Potential customers would
>> >> have to be desperate to wait for each page to unpeel like that.
>> >>
>> >> --
>> >> Mike Brind
>> >>
>> >> Steven Burn wrote:
>> >> > hehe, PlusNet ;o)
>> >> >
>> >> > --
>> >> > Regards
>> >> >
>> >> > Steven Burn
>> >> > Ur I.T. Mate Group
>> >> > www.it-mate.co.uk
>> >> >
>> >> > Keeping it FREE!
>> >> >
>> >> > "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
>> >> > news:1145135351.337275.53400 [at] u72g2000cwu.googlegroups.com...
>> >> > >
>> >> > > Steven Burn wrote:
>> >> > > > Woot!, another PN customer <g>
>> >> > > >
>> >> > >
>> >> > > PN? What's that then?
>> >> > >
>> >> > > --
>> >> > > Mike Brind
>> >> > >
>> >>
>> >
>> >
>>
>>
>
>
Re: Validate logins with ASP, MS Access and Cookies error
http://portal.plus.net/central/forums/
--
Regards
Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk
Keeping it FREE!
"malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
news:4442c636$0$33918$ed2619ec [at] ptn-nntp-reader03.plus.net...
> whats the url ?
>
> "Steven Burn" <somewhere [at] in-time.invalid> wrote in message
> news:Oas3WQaYGHA.4996 [at] TK2MSFTNGP03.phx.gbl...
> > Hop on over to their forums (my nick over there is MysteryFCM) for an
idea
> > ;o)
> >
> > --
> > Regards
> >
> > Steven Burn
> > Ur I.T. Mate Group
> > www.it-mate.co.uk
> >
> > Keeping it FREE!
> >
> > "malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
> > news:4442b589$0$2567$ed2619ec [at] ptn-nntp-reader02.plus.net...
> >> Excuse me for being a bit dim! but what the hell is that picture and
why
> > all
> >> the bad mouth over plusnet ?
> >>
> >> you guys wana let me in on the secret here?
> >>
> >> my msn messenger handle is malcolmk [at] fsmail.net
> >>
> >> cheers
> >> mal
> >>
> >>
> >>
> >> "Bob Lehmann" <nospam [at] dontbotherme.zzz> wrote in message
> >> news:ORxWjoZYGHA.3328 [at] TK2MSFTNGP02.phx.gbl...
> >> > It is even better in FireFox...
> >> > http://69.51.91.77/workbench/images/Untitled-1.gif
> >> >
> >> > Bob Lehmann
> >> >
> >> > "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
> >> > news:1145216119.201139.171120 [at] t31g2000cwb.googlegroups.com.. .
> >> >> Oh, I thought maybe it was the name of the some free code that the
op
> >> >> had been using, and that you had recognised it. Had a look at
PlusNet
> >> >> web site. How utterly, utterly horrible. Potential customers would
> >> >> have to be desperate to wait for each page to unpeel like that.
> >> >>
> >> >> --
> >> >> Mike Brind
> >> >>
> >> >> Steven Burn wrote:
> >> >> > hehe, PlusNet ;o)
> >> >> >
> >> >> > --
> >> >> > Regards
> >> >> >
> >> >> > Steven Burn
> >> >> > Ur I.T. Mate Group
> >> >> > www.it-mate.co.uk
> >> >> >
> >> >> > Keeping it FREE!
> >> >> >
> >> >> > "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
> >> >> > news:1145135351.337275.53400 [at] u72g2000cwu.googlegroups.com...
> >> >> > >
> >> >> > > Steven Burn wrote:
> >> >> > > > Woot!, another PN customer <g>
> >> >> > > >
> >> >> > >
> >> >> > > PN? What's that then?
> >> >> > >
> >> >> > > --
> >> >> > > Mike Brind
> >> >> > >
> >> >>
> >> >
> >> >
> >>
> >>
> >
> >
>
>
Re: Validate logins with ASP, MS Access and Cookies error
What good books can you recommend ? I am obviously interested in ASP and
basic scripts.
Regards
Malcolm
/?
> /?
> ///?
> /////?
> www.bankchargesrefunded.co.uk
> "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
> news:1145131736.516317.252350 [at] z34g2000cwc.googlegroups.com.. .
> Steve was pointing out that SELECT *(asterisk) is a BAD thing. SELECT
> * returns all the rows in the tables in your FROM clause. When we
> changed the SELECT statement to SELECT [name], UID FROM... it got round
> the SELECT * problem.
>
> If you plan to do much more ASP, I would advise looking for tutorials
> that explain the code they offer, rather than these kinds of free
> scripts. There are some excellent sites around, including
> www.asp101.com and www.learnasp.com.
>
> Another way to learn stuff is to make mistakes, and copy and paste the
> error messages into www.aspfaq.com.
>
> Good luck
>
> --
> Mike Brind
>
> malcolm wrote:
>> I have now changed the code which Mike advised and it now works.
>>
>> I have no idea how to do that Steven! I did read the article that you
>> refer
>> me too.
>>
>> I have not stopped using "Select" because I don't know what to replace it
>> with!! I have gone back over the trail and found this
>>
>> '// and NEVER use "Select * ..."
>>
>> '//
>>
>> '// http://aspfaq.com/show.asp?id 96
>>
>>
>>
>> I read that article. 2096 1st time but not sure how to implement the
>> changes
>> you recommend ?
>>
>>
>>
>>
>>
>> Regards
>>
>> Malcolm
>>
>>
>>
>>
>>
>> "Steven Burn" <somewhere [at] in-time.invalid> wrote in message
>> news:edTpQvLYGHA.4484 [at] TK2MSFTNGP02.phx.gbl...
>> > AGAIN, stop using "Select *" !!!!!!
>> >
>> > http://aspfaq.com/show.asp?id 96
>> >
>> > As for returning the users actual name, just select it from the DB;
>> >
>> > strSQL = "Select UsersName, UID From tblUsers Where UID = '" & strUID &
>> > "'"
>> >
>> > Where "UsersName" is the name of the field that holds the data you
>> > require.
>> >
>> > --
>> > Regards
>> >
>> > Steven Burn
>> > Ur I.T. Mate Group
>> > www.it-mate.co.uk
>> >
>> > Keeping it FREE!
>> >
>> > "malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
>> > news:444133fc$0$23199$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
>> >> Thanks Guys, i have now cleaned up the code and it is working ok. Just
>> >> one
>> >> thing I want to ask! on the login successful page it shows the
>> >> username
>> > aas
>> >> typed into the form UID field.. what I would like to do now is actully
>> >> return another column from the database that stores the users 1st name
>> >> :-)
>> >>
>> >> any tips
>> >>
>> >> here is the code I am using now. :-)
>> >>
>> >> <% [at] Language="VBScript"%>
>> >>
>> >> <!-- METADATA TYPE="typelib" FILE="C:\Program Files\Common
>> >> Files\System\ado\msado15.dll" -->
>> >> <!-- #include file="Connectionstring.asp" -->
>> >> <%
>> >>
>> >> ' variables
>> >> dim cnStr, rcSet, frmUID, frmPWD, sqlStr
>> >>
>> >> 'store form input into variables
>> >> frmUID = Request.Form("UID")
>> >> frmPWD = Request.Form("PWD")
>> >>
>> >> 'create connection and recordset objects
>> >> Set cnStr = Server.CreateObject("ADODB.Connection")
>> >>
>> >> ' defining database connection (connectionstring.asp)
>> >> cnStr.ConnectionString = path
>> >> cnStr.Provider = provider
>> >> cnStr.open
>> >>
>> >> ' execute sql and open as recordset
>> >>
>> >> sqlStr = "Select * From tblusers where UID = '" _
>> >> & Request.Form("UID") & "' and PWD = '" & Request.Form("PWD") &
>> >> "'"
>> >>
>> >> ' Opens the returned values from the SQL as a recordset,
>> >> ' ready for iteration by ASP
>> >> ' validate variables against database
>> >> // If (not rcSet.BOF) and (not rcSet.EOF) then
>> >>
>> >> If Len(frmUID) < 1 Then frmUID = "NULL"
>> >> If Len(frmPWD) < 1 Then frmPWD = "NULL"
>> >>
>> >> Set rcSet = cnStr.Execute(sqlStr)
>> >>
>> >> If NOT rcSet.EOF Then
>> >> response.cookies("validated_user") = frmUID
>> >> response.write "<h1>Login successful!</h1>"
>> >>
>> >> response.write "<p>Welcome " & rcSet(0) & "</p>"
>> >> else
>> >> response.write "Incorrect Username and/or Password"
>> >> end if
>> >>
>> >> cnStr.Close: Set cnStr = Nothing
>> >> Set rcSet = Nothing
>> >> %>
>> >>
>> >> I had to change this code
>> >> response.write "<p>Welcome " & rcSet(1) & "</p>"
>> >> to this code
>> >> response.write "<p>Welcome " & rcSet(0) & "</p>"
>> >> so that it would display the username and not the password ;-)
>> >> not bad for a guess. :-)
>> >>
>> >> Regards
>> >> Malcolm
>> >>
>> >>
>> >> "Steven Burn" <somewhere [at] in-time.invalid> wrote in message
>> >> news:e%237BQOLYGHA.3448 [at] TK2MSFTNGP04.phx.gbl...
>> >> > Change;
>> >> >
>> >> > sqlStr = "Select * From tblusers where UID = '" _
>> >> > & Request.Form("UID") & "' and PWD = '" & Request.Form("PWD") &
>> >> > "'"
>> >> >
>> >> > ' Opens the returned values from the SQL as a recordset,
>> >> > ' ready for iteration by ASP
>> >> > '// <<< LINE 53 >>> set rcSet = cnStr.Execute(sqlStr)
>> >> > ' validate variables against database
>> >> > // If (not rcSet.BOF) and (not rcSet.EOF) then
>> >> >
>> >> > '// Check before processing
>> >> > If Len(frmUsername) < 1 Then frmUsername = "NULL"
>> >> > If Len(frmPassword) < 1 Then frmPassword = "NULL"
>> >> >
>> >> > To;
>> >> >
>> >> > '// Check before processing
>> >> > If Len(frmUsername) < 1 Then frmUsername = "NULL"
>> >> > If Len(frmPassword) < 1 Then frmPassword = "NULL"
>> >> > Response.Write "<b><i>DEBUG</i><b><br>Username: " _
>> >> > & frmUID & "<br>Password: " & frmPWD
>> >> > sqlStr = "Select * From tblusers where UID = '" _
>> >> > & frmUID & "' and PWD = '" & frmPWD & "'"
>> >> >
>> >> > ' Opens the returned values from the SQL as a recordset,
>> >> > ' ready for iteration by ASP
>> >> > '// <<< LINE 53 >>> set rcSet = cnStr.Execute(sqlStr)
>> >> > ' validate variables against database
>> >> > // If (not rcSet.BOF) and (not rcSet.EOF) then
>> >> >
>> >> > --
>> >> > Regards
>> >> >
>> >> > Steven Burn
>> >> > Ur I.T. Mate Group
>> >> > www.it-mate.co.uk
>> >> >
>> >> > Keeping it FREE!
>> >> >
>> >> > "malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
>> >> > news:4441284e$0$23185$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
>> >> >> I am now presented with incorrect Username and/or Password. I have
>> > double
>> >> >> checked this.
>> >> >>
>> >> >> I now have the following code in my page
>> >> >>
>> >> >> <% [at] Language="VBScript"%>
>> >> >>
>> >> >> <!-- METADATA TYPE="typelib" FILE="C:\Program Files\Common
>> >> >> Files\System\ado\msado15.dll" -->
>> >> >> <!-- #include file="Connectionstring.asp" -->
>> >> >> <%
>> >> >> ' /////////////////////////////////////
>> >> >> ' login validation script
>> >> >> ' © Matt Millross
>> >> >> ' www.designplace.org
>> >> >> ' free for use as long as copyright notice left intact
>> >> >> ' For more scripts, visit www.designplace.org
>> >> >> ' /////////////////////////////////////
>> >> >>
>> >> >> ' variables
>> >> >> dim cnStr, rcSet, frmUID, frmPWD, sqlStr
>> >> >>
>> >> >> 'store form input into variables
>> >> >> frmUID = Request.Form("UID")
>> >> >> frmPWD = Request.Form("PWD")
>> >> >>
>> >> >> 'create connection and recordset objects
>> >> >> Set cnStr = Server.CreateObject("ADODB.Connection")
>> >> >> '// THIS IS NOT NEEDED!
>> >> >> '// Set rcSet = Server.CreateObject("ADODB.Recordset")
>> >> >>
>> >> >> ' defining database connection (connectionstring.asp)
>> >> >> cnStr.ConnectionString = path
>> >> >> cnStr.Provider = provider
>> >> >> cnStr.open
>> >> >>
>> >> >> ' execute sql and open as recordset
>> >> >> '// sqlStr = "Select * From tblusers where username = '" _
>> >> >> '// & Request.Form("UID") & "' and password = '" &
>> > Request.Form("PWD")
>> >> >> &
>> >> >> "'"
>> >> >> '// You've already stored the user/pass into a local var - use
>> >> >> them!
>> >> >> '// and NEVER use "Select * ..."
>> >> >> '//
>> >> >> '// http://aspfaq.com/show.asp?id 96
>> >> >>
>> >> >> sqlStr = "Select * From tblusers where UID = '" _
>> >> >> & Request.Form("UID") & "' and PWD = '" & Request.Form("PWD")
>> >> >> &
>> > "'"
>> >> >>
>> >> >> ' Opens the returned values from the SQL as a recordset,
>> >> >> ' ready for iteration by ASP
>> >> >> '// <<< LINE 53 >>> set rcSet = cnStr.Execute(sqlStr)
>> >> >> ' validate variables against database
>> >> >> // If (not rcSet.BOF) and (not rcSet.EOF) then
>> >> >>
>> >> >> '// Check before processing
>> >> >> If Len(frmUsername) < 1 Then frmUsername = "NULL"
>> >> >> If Len(frmPassword) < 1 Then frmPassword = "NULL"
>> >> >> '// Then go...
>> >> >> Set rcSet = cnStr.Execute(sqlStr)
>> >> >>
>> >> >> If NOT rcSet.EOF Then
>> >> >> response.cookies("validated_user") = frmUID
>> >> >> response.write "<h1>Login successful!</h1>"
>> >> >> '// Forget using rcSet.Fields, and just use rcSet
>> >> >> '// directly
>> >> >> response.write "<p>Welcome " & rcSet(1) & "</p>"
>> >> >> else
>> >> >> response.write "incorrect Username and/or Password"
>> >> >> end if
>> >> >>
>> >> >> '// Don't forget to cleanup after yourself
>> >> >> cnStr.Close: Set cnStr = Nothing
>> >> >> Set rcSet = Nothing
>> >> >> %>
>> >> >>
>> >> >>
>> >> >> Regards
>> >> >> Malcolm
>> >> >>
>> >> >>
>> >> >> "malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
>> >> >> news:4441273b$0$23177$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
>> >> >> > UID and PWD are the 2 fields in my database that hold the
>> > information.
>> >> >> >
>> >> >> > I have now changed the code
>> >> >> >
>> >> >> > "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
>> >> >> > news:1145119070.271743.314040 [at] z34g2000cwc.googlegroups.com.. .
>> >> >> >>
>> >> >> >> malcolm wrote:
>> >> >> >>> Hi, while trying to validate username and password on login
>> >> >> >>> form I
>> > am
>> >> >> >>> presented with the following error message
>> >> >> >>>
>> >> >> >>>
>> >> >> >>> Microsoft JET Database Engine error '80040e10'
>> >> >> >>>
>> >> >> >>> No value given for one or more required parameters.
>> >> >> >>>
>> >> >> >>> /vdateUsr.asp, line 53
>> >> >> >>>
>> >> >> >>> The 2 fields within the database are text fields (UID) and
>> >> >> >>> (PWD)
>> >> >> >>> these
>> >> >> >>> are
>> >> >> >>> spelt correctly!
>> >> >> >>>
>> >> >> >>
>> >> >> >> <snip>
>> >> >> >>> sqlStr = "Select * From tblusers where username = '" _
>> >> >> >>> & Request.Form("UID") & "' and password = '" &
>> > Request.Form("PWD")
>> >> > &
>> >> >> >>> "'"
>> >> >> >>>
>> >> >> >>
>> >> >> >> No - they're not spelt correctly. In your SQL statement you
>> >> >> >> refer
>> > to
>> >> >> >> two fields called username and password, yet you said they are
>> > called
>> >> >> >> UID and PWD. Which is correct?
>> >> >> >>
>> >> >> >> --
>> >> >> >> Mike Brind
>> >> >> >>
>> >> >> >
>> >> >> >
>> >> >>
>> >> >>
>> >> >
>> >> >
>> >>
>> >>
>> >
>> >
>
>
Re: Validate logins with ASP, MS Access and Cookies error
I have Beginning ASP 2.0 (Wrox) and ASP Developer's Guide (Osbourne).
Both are good for beginners. The technical docs can be found here:
http://msdn.microsoft.com/library/default.asp?url=3D/library /en-us/iissdk/h=
tml/2c40c3cf-90eb-41ca-ae2a-0ef33a651779.asp
--
Mike Brind
malcolm wrote:
> What good books can you recommend ? I am obviously interested in ASP and
> basic scripts.
>
> Regards
> Malcolm
>
> /?
> > /?
> > ///?
> > /////?
> > www.bankchargesrefunded.co.uk
> > "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
> > news:1145131736.516317.252350 [at] z34g2000cwc.googlegroups.com.. .
> > Steve was pointing out that SELECT *(asterisk) is a BAD thing. SELECT
> > * returns all the rows in the tables in your FROM clause. When we
> > changed the SELECT statement to SELECT [name], UID FROM... it got round
> > the SELECT * problem.
> >
> > If you plan to do much more ASP, I would advise looking for tutorials
> > that explain the code they offer, rather than these kinds of free
> > scripts. There are some excellent sites around, including
> > www.asp101.com and www.learnasp.com.
> >
> > Another way to learn stuff is to make mistakes, and copy and paste the
> > error messages into www.aspfaq.com.
> >
> > Good luck
> >
> > --
> > Mike Brind
> >
> > malcolm wrote:
> >> I have now changed the code which Mike advised and it now works.
> >>
> >> I have no idea how to do that Steven! I did read the article that you
> >> refer
> >> me too.
> >>
> >> I have not stopped using "Select" because I don't know what to replace=
it
> >> with!! I have gone back over the trail and found this
> >>
> >> '// and NEVER use "Select * ..."
> >>
> >> '//
> >>
> >> '// http://aspfaq.com/show.asp?id=3D2096
> >>
> >>
> >>
> >> I read that article. 2096 1st time but not sure how to implement the
> >> changes
> >> you recommend ?
> >>
> >>
> >>
> >>
> >>
> >> Regards
> >>
> >> Malcolm
> >>
> >>
> >>
> >>
> >>
> >> "Steven Burn" <somewhere [at] in-time.invalid> wrote in message
> >> news:edTpQvLYGHA.4484 [at] TK2MSFTNGP02.phx.gbl...
> >> > AGAIN, stop using "Select *" !!!!!!
> >> >
> >> > http://aspfaq.com/show.asp?id=3D2096
> >> >
> >> > As for returning the users actual name, just select it from the DB;
> >> >
> >> > strSQL =3D "Select UsersName, UID From tblUsers Where UID =3D '" & s=
trUID &
> >> > "'"
> >> >
> >> > Where "UsersName" is the name of the field that holds the data you
> >> > require.
> >> >
> >> > --
> >> > Regards
> >> >
> >> > Steven Burn
> >> > Ur I.T. Mate Group
> >> > www.it-mate.co.uk
> >> >
> >> > Keeping it FREE!
> >> >
> >> > "malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
> >> > news:444133fc$0$23199$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
> >> >> Thanks Guys, i have now cleaned up the code and it is working ok. J=
ust
> >> >> one
> >> >> thing I want to ask! on the login successful page it shows the
> >> >> username
> >> > aas
> >> >> typed into the form UID field.. what I would like to do now is actu=
lly
> >> >> return another column from the database that stores the users 1st n=
ame
> >> >> :-)
> >> >>
> >> >> any tips
> >> >>
> >> >> here is the code I am using now. :-)
> >> >>
> >> >> <% [at] Language=3D"VBScript"%>
> >> >>
> >> >> <!-- METADATA TYPE=3D"typelib" FILE=3D"C:\Program Files\Common
> >> >> Files\System\ado\msado15.dll" -->
> >> >> <!-- #include file=3D"Connectionstring.asp" -->
> >> >> <%
> >> >>
> >> >> ' variables
> >> >> dim cnStr, rcSet, frmUID, frmPWD, sqlStr
> >> >>
> >> >> 'store form input into variables
> >> >> frmUID =3D Request.Form("UID")
> >> >> frmPWD =3D Request.Form("PWD")
> >> >>
> >> >> 'create connection and recordset objects
> >> >> Set cnStr =3D Server.CreateObject("ADODB.Connection")
> >> >>
> >> >> ' defining database connection (connectionstring.asp)
> >> >> cnStr.ConnectionString =3D path
> >> >> cnStr.Provider =3D provider
> >> >> cnStr.open
> >> >>
> >> >> ' execute sql and open as recordset
> >> >>
> >> >> sqlStr =3D "Select * From tblusers where UID =3D '" _
> >> >> & Request.Form("UID") & "' and PWD =3D '" & Request.Form("PWD"=
) &
> >> >> "'"
> >> >>
> >> >> ' Opens the returned values from the SQL as a recordset,
> >> >> ' ready for iteration by ASP
> >> >> ' validate variables against database
> >> >> // If (not rcSet.BOF) and (not rcSet.EOF) then
> >> >>
> >> >> If Len(frmUID) < 1 Then frmUID =3D "NULL"
> >> >> If Len(frmPWD) < 1 Then frmPWD =3D "NULL"
> >> >>
> >> >> Set rcSet =3D cnStr.Execute(sqlStr)
> >> >>
> >> >> If NOT rcSet.EOF Then
> >> >> response.cookies("validated_user") =3D frmUID
> >> >> response.write "<h1>Login successful!</h1>"
> >> >>
> >> >> response.write "<p>Welcome " & rcSet(0) & "</p>"
> >> >> else
> >> >> response.write "Incorrect Username and/or Password"
> >> >> end if
> >> >>
> >> >> cnStr.Close: Set cnStr =3D Nothing
> >> >> Set rcSet =3D Nothing
> >> >> %>
> >> >>
> >> >> I had to change this code
> >> >> response.write "<p>Welcome " & rcSet(1) & "</p>"
> >> >> to this code
> >> >> response.write "<p>Welcome " & rcSet(0) & "</p>"
> >> >> so that it would display the username and not the password ;-)
> >> >> not bad for a guess. :-)
> >> >>
> >> >> Regards
> >> >> Malcolm
> >> >>
> >> >>
> >> >> "Steven Burn" <somewhere [at] in-time.invalid> wrote in message
> >> >> news:e%237BQOLYGHA.3448 [at] TK2MSFTNGP04.phx.gbl...
> >> >> > Change;
> >> >> >
> >> >> > sqlStr =3D "Select * From tblusers where UID =3D '" _
> >> >> > & Request.Form("UID") & "' and PWD =3D '" & Request.Form("PWD=
") &
> >> >> > "'"
> >> >> >
> >> >> > ' Opens the returned values from the SQL as a recordset,
> >> >> > ' ready for iteration by ASP
> >> >> > '// <<< LINE 53 >>> set rcSet =3D cnStr.Execute(sqlStr)
> >> >> > ' validate variables against database
> >> >> > // If (not rcSet.BOF) and (not rcSet.EOF) then
> >> >> >
> >> >> > '// Check before processing
> >> >> > If Len(frmUsername) < 1 Then frmUsername =3D "NULL"
> >> >> > If Len(frmPassword) < 1 Then frmPassword =3D "NULL"
> >> >> >
> >> >> > To;
> >> >> >
> >> >> > '// Check before processing
> >> >> > If Len(frmUsername) < 1 Then frmUsername =3D "NULL"
> >> >> > If Len(frmPassword) < 1 Then frmPassword =3D "NULL"
> >> >> > Response.Write "<b><i>DEBUG</i><b><br>Username: " _
> >> >> > & frmUID & "<br>Password: " & frmPWD
> >> >> > sqlStr =3D "Select * From tblusers where UID =3D '" _
> >> >> > & frmUID & "' and PWD =3D '" & frmPWD & "'"
> >> >> >
> >> >> > ' Opens the returned values from the SQL as a recordset,
> >> >> > ' ready for iteration by ASP
> >> >> > '// <<< LINE 53 >>> set rcSet =3D cnStr.Execute(sqlStr)
> >> >> > ' validate variables against database
> >> >> > // If (not rcSet.BOF) and (not rcSet.EOF) then
> >> >> >
> >> >> > --
> >> >> > Regards
> >> >> >
> >> >> > Steven Burn
> >> >> > Ur I.T. Mate Group
> >> >> > www.it-mate.co.uk
> >> >> >
> >> >> > Keeping it FREE!
> >> >> >
> >> >> > "malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
> >> >> > news:4441284e$0$23185$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
> >> >> >> I am now presented with incorrect Username and/or Password. I ha=
ve
> >> > double
> >> >> >> checked this.
> >> >> >>
> >> >> >> I now have the following code in my page
> >> >> >>
> >> >> >> <% [at] Language=3D"VBScript"%>
> >> >> >>
> >> >> >> <!-- METADATA TYPE=3D"typelib" FILE=3D"C:\Program Files\Common
> >> >> >> Files\System\ado\msado15.dll" -->
> >> >> >> <!-- #include file=3D"Connectionstring.asp" -->
> >> >> >> <%
> >> >> >> ' /////////////////////////////////////
> >> >> >> ' login validation script
> >> >> >> ' =A9 Matt Millross
> >> >> >> ' www.designplace.org
> >> >> >> ' free for use as long as copyright notice left intact
> >> >> >> ' For more scripts, visit www.designplace.org
> >> >> >> ' /////////////////////////////////////
> >> >> >>
> >> >> >> ' variables
> >> >> >> dim cnStr, rcSet, frmUID, frmPWD, sqlStr
> >> >> >>
> >> >> >> 'store form input into variables
> >> >> >> frmUID =3D Request.Form("UID")
> >> >> >> frmPWD =3D Request.Form("PWD")
> >> >> >>
> >> >> >> 'create connection and recordset objects
> >> >> >> Set cnStr =3D Server.CreateObject("ADODB.Connection")
> >> >> >> '// THIS IS NOT NEEDED!
> >> >> >> '// Set rcSet =3D Server.CreateObject("ADODB.Recordset")
> >> >> >>
> >> >> >> ' defining database connection (connectionstring.asp)
> >> >> >> cnStr.ConnectionString =3D path
> >> >> >> cnStr.Provider =3D provider
> >> >> >> cnStr.open
> >> >> >>
> >> >> >> ' execute sql and open as recordset
> >> >> >> '// sqlStr =3D "Select * From tblusers where username =3D '" _
> >> >> >> '// & Request.Form("UID") & "' and password =3D '" &
> >> > Request.Form("PWD")
> >> >> >> &
> >> >> >> "'"
> >> >> >> '// You've already stored the user/pass into a local var - use
> >> >> >> them!
> >> >> >> '// and NEVER use "Select * ..."
> >> >> >> '//
> >> >> >> '// http://aspfaq.com/show.asp?id=3D2096
> >> >> >>
> >> >> >> sqlStr =3D "Select * From tblusers where UID =3D '" _
> >> >> >> & Request.Form("UID") & "' and PWD =3D '" & Request.Form("P=
WD")
> >> >> >> &
> >> > "'"
> >> >> >>
> >> >> >> ' Opens the returned values from the SQL as a recordset,
> >> >> >> ' ready for iteration by ASP
> >> >> >> '// <<< LINE 53 >>> set rcSet =3D cnStr.Execute(sqlStr)
> >> >> >> ' validate variables against database
> >> >> >> // If (not rcSet.BOF) and (not rcSet.EOF) then
> >> >> >>
> >> >> >> '// Check before processing
> >> >> >> If Len(frmUsername) < 1 Then frmUsername =3D "NULL"
> >> >> >> If Len(frmPassword) < 1 Then frmPassword =3D "NULL"
> >> >> >> '// Then go...
> >> >> >> Set rcSet =3D cnStr.Execute(sqlStr)
> >> >> >>
> >> >> >> If NOT rcSet.EOF Then
> >> >> >> response.cookies("validated_user") =3D frmUID
> >> >> >> response.write "<h1>Login successful!</h1>"
> >> >> >> '// Forget using rcSet.Fields, and just use rcSet
> >> >> >> '// directly
> >> >> >> response.write "<p>Welcome " & rcSet(1) & "</p>"
> >> >> >> else
> >> >> >> response.write "incorrect Username and/or Password"
> >> >> >> end if
> >> >> >>
> >> >> >> '// Don't forget to cleanup after yourself
> >> >> >> cnStr.Close: Set cnStr =3D Nothing
> >> >> >> Set rcSet =3D Nothing
> >> >> >> %>
> >> >> >>
> >> >> >>
> >> >> >> Regards
> >> >> >> Malcolm
> >> >> >>
> >> >> >>
> >> >> >> "malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
> >> >> >> news:4441273b$0$23177$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
> >> >> >> > UID and PWD are the 2 fields in my database that hold the
> >> > information.
> >> >> >> >
> >> >> >> > I have now changed the code
> >> >> >> >
> >> >> >> > "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
> >> >> >> > news:1145119070.271743.314040 [at] z34g2000cwc.googlegroups.com.. .
> >> >> >> >>
> >> >> >> >> malcolm wrote:
> >> >> >> >>> Hi, while trying to validate username and password on login
> >> >> >> >>> form I
> >> > am
> >> >> >> >>> presented with the following error message
> >> >> >> >>>
> >> >> >> >>>
> >> >> >> >>> Microsoft JET Database Engine error '80040e10'
> >> >> >> >>>
> >> >> >> >>> No value given for one or more required parameters.
> >> >> >> >>>
> >> >> >> >>> /vdateUsr.asp, line 53
> >> >> >> >>>
> >> >> >> >>> The 2 fields within the database are text fields (UID) and
> >> >> >> >>> (PWD)
> >> >> >> >>> these
> >> >> >> >>> are
> >> >> >> >>> spelt correctly!
> >> >> >> >>>
> >> >> >> >>
> >> >> >> >> <snip>
> >> >> >> >>> sqlStr =3D "Select * From tblusers where username =3D '" _
> >> >> >> >>> & Request.Form("UID") & "' and password =3D '" &
> >> > Request.Form("PWD")
> >> >> > &
> >> >> >> >>> "'"
> >> >> >> >>>
> >> >> >> >>
> >> >> >> >> No - they're not spelt correctly. In your SQL statement you
> >> >> >> >> refer
> >> > to
> >> >> >> >> two fields called username and password, yet you said they are
> >> > called
> >> >> >> >> UID and PWD. Which is correct?
> >> >> >> >>
> >> >> >> >> --
> >> >> >> >> Mike Brind
> >> >> >> >>
> >> >> >> >
> >> >> >> >
> >> >> >>
> >> >> >>
> >> >> >
> >> >> >
> >> >>
> >> >>
> >> >
> >> >
> >
> >
Re: Validate logins with ASP, MS Access and Cookies error
dam, this is a long ass thread
another good way to learn is to download something like the free version of
aspprotect
www.aspprotect.com
its asp source code and you can learn a lot from looking the code over oce
you get it running
"malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
news:4442d56c$0$33905$ed2619ec [at] ptn-nntp-reader03.plus.net...
> What good books can you recommend ? I am obviously interested in ASP and
> basic scripts.
>
> Regards
> Malcolm
>
> /?
>> /?
>> ///?
>> /////?
>> www.bankchargesrefunded.co.uk
>> "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
>> news:1145131736.516317.252350 [at] z34g2000cwc.googlegroups.com.. .
>> Steve was pointing out that SELECT *(asterisk) is a BAD thing. SELECT
>> * returns all the rows in the tables in your FROM clause. When we
>> changed the SELECT statement to SELECT [name], UID FROM... it got round
>> the SELECT * problem.
>>
>> If you plan to do much more ASP, I would advise looking for tutorials
>> that explain the code they offer, rather than these kinds of free
>> scripts. There are some excellent sites around, including
>> www.asp101.com and www.learnasp.com.
>>
>> Another way to learn stuff is to make mistakes, and copy and paste the
>> error messages into www.aspfaq.com.
>>
>> Good luck
>>
>> --
>> Mike Brind
>>
>> malcolm wrote:
>>> I have now changed the code which Mike advised and it now works.
>>>
>>> I have no idea how to do that Steven! I did read the article that you
>>> refer
>>> me too.
>>>
>>> I have not stopped using "Select" because I don't know what to replace
>>> it
>>> with!! I have gone back over the trail and found this
>>>
>>> '// and NEVER use "Select * ..."
>>>
>>> '//
>>>
>>> '// http://aspfaq.com/show.asp?id 96
>>>
>>>
>>>
>>> I read that article. 2096 1st time but not sure how to implement the
>>> changes
>>> you recommend ?
>>>
>>>
>>>
>>>
>>>
>>> Regards
>>>
>>> Malcolm
>>>
>>>
>>>
>>>
>>>
>>> "Steven Burn" <somewhere [at] in-time.invalid> wrote in message
>>> news:edTpQvLYGHA.4484 [at] TK2MSFTNGP02.phx.gbl...
>>> > AGAIN, stop using "Select *" !!!!!!
>>> >
>>> > http://aspfaq.com/show.asp?id 96
>>> >
>>> > As for returning the users actual name, just select it from the DB;
>>> >
>>> > strSQL = "Select UsersName, UID From tblUsers Where UID = '" & strUID
>>> > &
>>> > "'"
>>> >
>>> > Where "UsersName" is the name of the field that holds the data you
>>> > require.
>>> >
>>> > --
>>> > Regards
>>> >
>>> > Steven Burn
>>> > Ur I.T. Mate Group
>>> > www.it-mate.co.uk
>>> >
>>> > Keeping it FREE!
>>> >
>>> > "malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
>>> > news:444133fc$0$23199$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
>>> >> Thanks Guys, i have now cleaned up the code and it is working ok.
>>> >> Just
>>> >> one
>>> >> thing I want to ask! on the login successful page it shows the
>>> >> username
>>> > aas
>>> >> typed into the form UID field.. what I would like to do now is
>>> >> actully
>>> >> return another column from the database that stores the users 1st
>>> >> name
>>> >> :-)
>>> >>
>>> >> any tips
>>> >>
>>> >> here is the code I am using now. :-)
>>> >>
>>> >> <% [at] Language="VBScript"%>
>>> >>
>>> >> <!-- METADATA TYPE="typelib" FILE="C:\Program Files\Common
>>> >> Files\System\ado\msado15.dll" -->
>>> >> <!-- #include file="Connectionstring.asp" -->
>>> >> <%
>>> >>
>>> >> ' variables
>>> >> dim cnStr, rcSet, frmUID, frmPWD, sqlStr
>>> >>
>>> >> 'store form input into variables
>>> >> frmUID = Request.Form("UID")
>>> >> frmPWD = Request.Form("PWD")
>>> >>
>>> >> 'create connection and recordset objects
>>> >> Set cnStr = Server.CreateObject("ADODB.Connection")
>>> >>
>>> >> ' defining database connection (connectionstring.asp)
>>> >> cnStr.ConnectionString = path
>>> >> cnStr.Provider = provider
>>> >> cnStr.open
>>> >>
>>> >> ' execute sql and open as recordset
>>> >>
>>> >> sqlStr = "Select * From tblusers where UID = '" _
>>> >> & Request.Form("UID") & "' and PWD = '" & Request.Form("PWD") &
>>> >> "'"
>>> >>
>>> >> ' Opens the returned values from the SQL as a recordset,
>>> >> ' ready for iteration by ASP
>>> >> ' validate variables against database
>>> >> // If (not rcSet.BOF) and (not rcSet.EOF) then
>>> >>
>>> >> If Len(frmUID) < 1 Then frmUID = "NULL"
>>> >> If Len(frmPWD) < 1 Then frmPWD = "NULL"
>>> >>
>>> >> Set rcSet = cnStr.Execute(sqlStr)
>>> >>
>>> >> If NOT rcSet.EOF Then
>>> >> response.cookies("validated_user") = frmUID
>>> >> response.write "<h1>Login successful!</h1>"
>>> >>
>>> >> response.write "<p>Welcome " & rcSet(0) & "</p>"
>>> >> else
>>> >> response.write "Incorrect Username and/or Password"
>>> >> end if
>>> >>
>>> >> cnStr.Close: Set cnStr = Nothing
>>> >> Set rcSet = Nothing
>>> >> %>
>>> >>
>>> >> I had to change this code
>>> >> response.write "<p>Welcome " & rcSet(1) & "</p>"
>>> >> to this code
>>> >> response.write "<p>Welcome " & rcSet(0) & "</p>"
>>> >> so that it would display the username and not the password ;-)
>>> >> not bad for a guess. :-)
>>> >>
>>> >> Regards
>>> >> Malcolm
>>> >>
>>> >>
>>> >> "Steven Burn" <somewhere [at] in-time.invalid> wrote in message
>>> >> news:e%237BQOLYGHA.3448 [at] TK2MSFTNGP04.phx.gbl...
>>> >> > Change;
>>> >> >
>>> >> > sqlStr = "Select * From tblusers where UID = '" _
>>> >> > & Request.Form("UID") & "' and PWD = '" & Request.Form("PWD") &
>>> >> > "'"
>>> >> >
>>> >> > ' Opens the returned values from the SQL as a recordset,
>>> >> > ' ready for iteration by ASP
>>> >> > '// <<< LINE 53 >>> set rcSet = cnStr.Execute(sqlStr)
>>> >> > ' validate variables against database
>>> >> > // If (not rcSet.BOF) and (not rcSet.EOF) then
>>> >> >
>>> >> > '// Check before processing
>>> >> > If Len(frmUsername) < 1 Then frmUsername = "NULL"
>>> >> > If Len(frmPassword) < 1 Then frmPassword = "NULL"
>>> >> >
>>> >> > To;
>>> >> >
>>> >> > '// Check before processing
>>> >> > If Len(frmUsername) < 1 Then frmUsername = "NULL"
>>> >> > If Len(frmPassword) < 1 Then frmPassword = "NULL"
>>> >> > Response.Write "<b><i>DEBUG</i><b><br>Username: " _
>>> >> > & frmUID & "<br>Password: " & frmPWD
>>> >> > sqlStr = "Select * From tblusers where UID = '" _
>>> >> > & frmUID & "' and PWD = '" & frmPWD & "'"
>>> >> >
>>> >> > ' Opens the returned values from the SQL as a recordset,
>>> >> > ' ready for iteration by ASP
>>> >> > '// <<< LINE 53 >>> set rcSet = cnStr.Execute(sqlStr)
>>> >> > ' validate variables against database
>>> >> > // If (not rcSet.BOF) and (not rcSet.EOF) then
>>> >> >
>>> >> > --
>>> >> > Regards
>>> >> >
>>> >> > Steven Burn
>>> >> > Ur I.T. Mate Group
>>> >> > www.it-mate.co.uk
>>> >> >
>>> >> > Keeping it FREE!
>>> >> >
>>> >> > "malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
>>> >> > news:4441284e$0$23185$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
>>> >> >> I am now presented with incorrect Username and/or Password. I have
>>> > double
>>> >> >> checked this.
>>> >> >>
>>> >> >> I now have the following code in my page
>>> >> >>
>>> >> >> <% [at] Language="VBScript"%>
>>> >> >>
>>> >> >> <!-- METADATA TYPE="typelib" FILE="C:\Program Files\Common
>>> >> >> Files\System\ado\msado15.dll" -->
>>> >> >> <!-- #include file="Connectionstring.asp" -->
>>> >> >> <%
>>> >> >> ' /////////////////////////////////////
>>> >> >> ' login validation script
>>> >> >> ' © Matt Millross
>>> >> >> ' www.designplace.org
>>> >> >> ' free for use as long as copyright notice left intact
>>> >> >> ' For more scripts, visit www.designplace.org
>>> >> >> ' /////////////////////////////////////
>>> >> >>
>>> >> >> ' variables
>>> >> >> dim cnStr, rcSet, frmUID, frmPWD, sqlStr
>>> >> >>
>>> >> >> 'store form input into variables
>>> >> >> frmUID = Request.Form("UID")
>>> >> >> frmPWD = Request.Form("PWD")
>>> >> >>
>>> >> >> 'create connection and recordset objects
>>> >> >> Set cnStr = Server.CreateObject("ADODB.Connection")
>>> >> >> '// THIS IS NOT NEEDED!
>>> >> >> '// Set rcSet = Server.CreateObject("ADODB.Recordset")
>>> >> >>
>>> >> >> ' defining database connection (connectionstring.asp)
>>> >> >> cnStr.ConnectionString = path
>>> >> >> cnStr.Provider = provider
>>> >> >> cnStr.open
>>> >> >>
>>> >> >> ' execute sql and open as recordset
>>> >> >> '// sqlStr = "Select * From tblusers where username = '" _
>>> >> >> '// & Request.Form("UID") & "' and password = '" &
>>> > Request.Form("PWD")
>>> >> >> &
>>> >> >> "'"
>>> >> >> '// You've already stored the user/pass into a local var - use
>>> >> >> them!
>>> >> >> '// and NEVER use "Select * ..."
>>> >> >> '//
>>> >> >> '// http://aspfaq.com/show.asp?id 96
>>> >> >>
>>> >> >> sqlStr = "Select * From tblusers where UID = '" _
>>> >> >> & Request.Form("UID") & "' and PWD = '" & Request.Form("PWD")
>>> >> >> &
>>> > "'"
>>> >> >>
>>> >> >> ' Opens the returned values from the SQL as a recordset,
>>> >> >> ' ready for iteration by ASP
>>> >> >> '// <<< LINE 53 >>> set rcSet = cnStr.Execute(sqlStr)
>>> >> >> ' validate variables against database
>>> >> >> // If (not rcSet.BOF) and (not rcSet.EOF) then
>>> >> >>
>>> >> >> '// Check before processing
>>> >> >> If Len(frmUsername) < 1 Then frmUsername = "NULL"
>>> >> >> If Len(frmPassword) < 1 Then frmPassword = "NULL"
>>> >> >> '// Then go...
>>> >> >> Set rcSet = cnStr.Execute(sqlStr)
>>> >> >>
>>> >> >> If NOT rcSet.EOF Then
>>> >> >> response.cookies("validated_user") = frmUID
>>> >> >> response.write "<h1>Login successful!</h1>"
>>> >> >> '// Forget using rcSet.Fields, and just use rcSet
>>> >> >> '// directly
>>> >> >> response.write "<p>Welcome " & rcSet(1) & "</p>"
>>> >> >> else
>>> >> >> response.write "incorrect Username and/or Password"
>>> >> >> end if
>>> >> >>
>>> >> >> '// Don't forget to cleanup after yourself
>>> >> >> cnStr.Close: Set cnStr = Nothing
>>> >> >> Set rcSet = Nothing
>>> >> >> %>
>>> >> >>
>>> >> >>
>>> >> >> Regards
>>> >> >> Malcolm
>>> >> >>
>>> >> >>
>>> >> >> "malcolm" <malcolm.whyte [at] malcolmk.plus.com> wrote in message
>>> >> >> news:4441273b$0$23177$ed2e19e4 [at] ptn-nntp-reader04.plus.net...
>>> >> >> > UID and PWD are the 2 fields in my database that hold the
>>> > information.
>>> >> >> >
>>> >> >> > I have now changed the code
>>> >> >> >
>>> >> >> > "Mike Brind" <paxtonend [at] hotmail.com> wrote in message
>>> >> >> > news:1145119070.271743.314040 [at] z34g2000cwc.googlegroups.com.. .
>>> >> >> >>
>>> >> >> >> malcolm wrote:
>>> >> >> >>> Hi, while trying to validate username and password on login
>>> >> >> >>> form I
>>> > am
>>> >> >> >>> presented with the following error message
>>> >> >> >>>
>>> >> >> >>>
>>> >> >> >>> Microsoft JET Database Engine error '80040e10'
>>> >> >> >>>
>>> >> >> >>> No value given for one or more required parameters.
>>> >> >> >>>
>>> >> >> >>> /vdateUsr.asp, line 53
>>> >> >> >>>
>>> >> >> >>> The 2 fields within the database are text fields (UID) and
>>> >> >> >>> (PWD)
>>> >> >> >>> these
>>> >> >> >>> are
>>> >> >> >>> spelt correctly!
>>> >> >> >>>
>>> >> >> >>
>>> >> >> >> <snip>
>>> >> >> >>> sqlStr = "Select * From tblusers where username = '" _
>>> >> >> >>> & Request.Form("UID") & "' and password = '" &
>>> > Request.Form("PWD")
>>> >> > &
>>> >> >> >>> "'"
>>> >> >> >>>
>>> >> >> >>
>>> >> >> >> No - they're not spelt correctly. In your SQL statement you
>>> >> >> >> refer
>>> > to
>>> >> >> >> two fields called username and password, yet you said they are
>>> > called
>>> >> >> >> UID and PWD. Which is correct?
>>> >> >> >>
>>> >> >> >> --
>>> >> >> >> Mike Brind
>>> >> >> >>
>>> >> >> >
>>> >> >> >
>>> >> >>
>>> >> >>
>>> >> >
>>> >> >
>>> >>
>>> >>
>>> >
>>> >
>>
>>
>
>
Re: Validate logins with ASP, MS Access and Cookies error
Malcom,
Hi here from The Netherlands. I read your question, and the only thing I
can see so far is that it might be possible that your UID and PWD in
your Request.Form or empty. I think you should check whether these
variables are empty or not using the IsEmpty(Request.Form("UID")) before
assigning a value that might not be there. What happens when you
hardcode a username and password in your SQL query, just to check
whether the SQL is not wrong??
Kind regards,
Emil Cristen
malcolm schreef:
> Hi, while trying to validate username and password on login form I am
> presented with the following error message
>
>
> Microsoft JET Database Engine error '80040e10'
>
> No value given for one or more required parameters.
>
> /vdateUsr.asp, line 53
>
> The 2 fields within the database are text fields (UID) and (PWD) these are
> spelt correctly!
>
> This is the code that I am using:
>
> <% [at] Language=VBScript%>
>
> <!-- METADATA TYPE="typelib"
> FILE="C:\Program Files\Common
> Files\System\ado\msado15.dll" -->
> <!-- #include file="Connectionstring.asp" -->
>
>
> <%
> ' /////////////////////////////////////
> ' login validation script
> ' © Matt Millross
> ' www.designplace.org
> ' free for use as long as copyright notice left intact
> ' For more scripts, visit www.designplace.org
> ' /////////////////////////////////////
>
> ' variables
> dim cnStr
> dim rcSet
> dim frmUsername
> dim frmPassword
> dim sqlStr
>
> 'store form input into variables
> frmUsername = Request.Form("UID")
> frmPassword = Request.Form("PWD")
>
> 'create connection and recordset objects
> Set cnStr = Server.CreateObject("ADODB.Connection")
> Set rcSet = Server.CreateObject("ADODB.Recordset")
>
> ' defining database connection (connectionstring.asp)
> cnStr.ConnectionString = path
> cnStr.Provider = provider
> cnStr.open
>
> ' execute sql and open as recordset
> sqlStr = "Select * From tblusers where username = '" _
> & Request.Form("UID") & "' and password = '" & Request.Form("PWD") & "'"
>
> ' Opens the returned values from the SQL as a recordset, ready for iteration
> by ASP
> <<< LINE 53 >>> set rcSet = cnStr.Execute(sqlStr)
> ' validate variables against database
> If (not rcSet.BOF) and (not rcSet.EOF) then
> response.cookies("validated_user") = frmUsername
> response.write "<h1>Login successful!</h1>"
> response.write "<p>Welcome " & rcSet.fields(1) & "</p>"
> else
> response.write "incorrect username and/or password"
> end if
> %>
>
> Unfortunately I am new to all this and would welcome any feedback on this
> error.
>
> Malcolm
>
>
>
>