Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


vbscript for web login page

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,60292
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> vbscript for web login page
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 vbscript for web login page - 5/16/2008 3:36:15 AM   
  dartcoach


Posts: 4
Score: 0
Joined: 5/16/2008
Status: offline
Hi all!
I'm brand new to this forum, and also brand new to vbscript.

I'm trying to create a login page for our customers to submit service orders.

I've got an Access 2007 db on the web server for username and password.

Here's my problem:

I can't seem to get the connection to the db to work.

I don't want to use ASP - just straight VBScript.  (I've been coding VB for a long time and it's easier for me!)

Here's what I have so far:

<html>
<head>
<script language="vbscript">
Sub CheckEntries()
Dim DBCON
dim RS
dim SQL
msgbox "hello"
set DBCON=Server.CreateObject("ADODB.Connection")
DBCON.Provider="Microsoft.ACE.OLEDB.12.0"
DBCON.Open("c:\users.accdb")
msgbox "Hello!"
set RS=Server.CreateObject("ADODB.recordset")
RS.Open "Select * from users", DBCON
do until RS.eof
for each x in RS.Fields
  Response.Write(x.name)
  Response.Write(" = ")
  Response.Write(x.value)
next
msgbox "Goodbye!"
RS.close
DBCON.close
End Sub
</script>
</head>
<body bgcolor="#ffffff" background="parchment.jpg">
<form name="loginform" onsubmit="CheckEntries()">
<input name="UserName" type=text id="username">
<input name="btnSend" type=submit value="Request Quote">
</form>
</body>
</html>

Any help would be greatly appreciated!

Thanks in advance.

_____________________________

dartcoach
 
 
Post #: 1
 
 RE: vbscript for web login page - 5/16/2008 4:15:35 AM   
  dartcoach


Posts: 4
Score: 0
Joined: 5/16/2008
Status: offline
Hi All,

Got it working!  1 problem though:

Each time I open the login page, I get ADO warning messages about the provider being unsafe.

Any idea on how to get rid of it?

Thanks in advance!

_____________________________

dartcoach

(in reply to dartcoach)
 
 
Post #: 2
 
 RE: vbscript for web login page - 5/16/2008 10:11:07 AM   
  TNO


Posts: 1284
Score: 12
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
I'm honestly confused on how you got it to work without ASP. did you do this?


<script language="vbscript" runat="server">


What is your current code?

_____________________________

To iterate is human, to recurse divine. -- L. Peter Deutsch

(in reply to dartcoach)
 
 
Post #: 3
 
 RE: vbscript for web login page - 5/17/2008 3:28:20 AM   
  dartcoach


Posts: 4
Score: 0
Joined: 5/16/2008
Status: offline
Here's the current code for the page:

<html>
<head>
<script language="vbscript">
Option Explicit
' define constants of ADO
Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adUseClient = 3
' define the Access DB path
Const DBPath = "C:\users.accdb"
Main()
Sub Main
' create adodb connection & recordset objects
Dim objConn
Set objConn = CreateObject("ADODB.Connection")
Dim objRecordSet
Set objRecordSet = CreateObject("ADODB.Recordset")
objRecordset.CursorLocation = adUseClient
dim objValid
' define query
Dim strSQLQuery
' msgbox "UserName: " & document.loginform.username.value
strSQLQuery = "SELECT * FROM login WHERE username='" & document.loginform.username.value & "'" & " AND password='" & document.loginform.password.value & "'"
msgbox strSQLQuery
If QueryTable(objConn, objRecordSet, strSQLQuery) Then 
msgbox "Hello!"
window.location.href = "_web/index.htm" 
Else
msgbox "No records found matching your query!"
response.redirect ("underconstruction.html")
End If
' close connections
objRecordSet.Close
objConn.Close
End Sub
Sub varRedirect
If QueryTable(objConn, objRecordSet, strSQLQuery) Then 
msgbox "Hello!"
window.location.href = "/_web/index.htm" 
Else
msgbox "trying to redirect"
response.redirect ("underconstruction.htm")
End If
End Sub
Function QueryTable(objConn, objRecordSet, strQuery)
objConn.Open "Provider=Microsoft.ACE.OLEDB.12.0; Persist Security Info=False; Data Source=" & DBPath
objRecordSet.Open strQuery, objConn, adOpenStatic, adLockOptimistic
' if the query returns a value then move to the first record & return true
If Not objRecordSet.EOF Then
objRecordSet.MoveFirst
QueryTable = True
Else
' return false if query do not return anything
QueryTable = False
End If
End Function
</script>
</Head>
<body bgcolor="#ffffff" background="parchment.jpg">
<form name="loginform" method="post" onsubmit="Main()" action="varRedirect">
<span class="bodytext">User Name: &nbsp<input name="UserName" type=text id="username"><br />
<span class="bodytext">Password: &nbsp<input name="Password" type=password id="password"><br />
<input name="btnSend" type=submit value="Login">
</form>
</body>
</html>

Page works as far as validating the username and password.  Redirect doesn't and the pages are valid.

I also still get the ADO warnings which I would like to suppress.

Thanks!

_____________________________

dartcoach

(in reply to TNO)
 
 
Post #: 4
 
 RE: vbscript for web login page - 5/17/2008 8:14:05 AM   
  TNO


Posts: 1284
Score: 12
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
You're getting warnings because the webpage is accessing a database on your computer, not the server, redirect is also failing then I assume for the same reason since your page is set up for the client. Hence my question about runat="server".

_____________________________

To iterate is human, to recurse divine. -- L. Peter Deutsch

(in reply to dartcoach)
 
 
Post #: 5
 
 RE: vbscript for web login page - 5/19/2008 3:11:08 AM   
  dartcoach


Posts: 4
Score: 0
Joined: 5/16/2008
Status: offline
TNO,

Thanks!  I've added the runat="server" to the page.

I have to get my webserver admin to change some settings to allow the page to run though.
As soon as they do that, I'll try the test again and let you know.

Thanks again!

_____________________________

dartcoach

(in reply to TNO)
 
 
Post #: 6
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> vbscript for web login page Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts