Solved

Is there a VBScript way of doing this?

Posted on 2011-03-16
8
289 Views
Last Modified: 2012-06-27
Below is some HTML and Javascript that sends a form with some hard coded values (name="username" id="mod_login_username" value="candidate")

Ideally I would like to be able to run this using VBScript instead, and my parameters are variables stored in a database.

I'm comfortable writing a stored procedure that fetches the username and password from the database. I'm comfortable writing an IF statement that processes the next section of code OR redirects the user....

What I would like to do though, is not use HTML or Javascript, so the "next section of code" ideally would be a VBScript function that replaces the Form Post being called, and allows for the values to be called from the database....

So it would look like -

Stored Procedure
Recordset creation
IF Recordset not Null then
Replacement VBScript (Fot HTML / Javascript)
Else Redirect
End If

Is this possible?

Please advise ---- Many thanks :)
<form method="post" action="http://www.site.co.uk/index.php" name="myForm" id="myForm">
<input type="hidden" name="username" id="mod_login_username" value="candidate" />
<input type="hidden" id="mod_login_password" name="passwd" value="candidate" />
</form>
<!-- now send the form! -->
<script type='text/javascript'>document.myForm.submit();</script>

Open in new window

0
Comment
Question by:garethtnash
  • 4
  • 3
8 Comments
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 35153652
Perhaps you can use ASP to create a XMLHTTP object to send then request to http://www.site.co.uk/index.php, with login parameters required.

Are you trying to run the checking in a web page or in a SP ?
0
 
LVL 1

Expert Comment

by:BigMonkeyHead
ID: 35156722
I think I understand what you're asking - and if I do, yes it's possible - you just need to embed your VBScript in your HTML.


<html>
<head>
</head>
<body>
<%
' ASP code to execute SQL query / stored procedure
IF Recordset not Null then
    ' I forget the syntax for getting data from your recordset, 
    '     but it's not difficult
    theUserName = Recordset("username") 
    theIDdata = Recordset("id")
    theCandidateData = Recordset("candidate")
%>
<form method="post" action="http://www.site.co.uk/index.php" name="myForm" id="myForm">
<input type="hidden" name="<% Response.Write theUserName %>" id="<% Response.Write theIDdata %>" value="<% Response.Write theCandidateData %>" />
<input type="hidden" id="mod_login_password" name="passwd" value="candidate" />
</form>
<%
else
   Response.Write myRedirectURL
end if
%>
</body>
</html>

Open in new window

0
 

Author Comment

by:garethtnash
ID: 35159720
Thanks, but.... I was actually hoping to organise the form post server side, not client side.... so the page that processes the vbscript is never seen...

Any suggestions? Thank you :)
0
 
LVL 1

Expert Comment

by:BigMonkeyHead
ID: 35161027
Not sure what you mean - the ASP is processed server side - only HTML is sent to the client.
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 1

Expert Comment

by:BigMonkeyHead
ID: 35164538
If it makes it clearer, this is functionally the same:
IF Recordset not Null then
    ' I forget the syntax for getting data from your recordset, 
    '     but it's not difficult
    theUserName = Recordset("username") 
    theIDdata = Recordset("id")
    theCandidateData = Recordset("candidate")

    Response.Write "<form method='post' action='http://www.site.co.uk/index.php' name='myForm' id='myForm'>
<input type='hidden' name='" & theUserName &"' id='" & theIDdata "' value='" & theCandidateData "' />
<input type='hidden' id='mod_login_password' name='passwd' value='candidate' />
</form>"
else
   Response.Write myRedirectURL
end if

Open in new window

0
 

Author Comment

by:garethtnash
ID: 35168055
Does that process, submit the form? thanks
0
 
LVL 1

Accepted Solution

by:
BigMonkeyHead earned 500 total points
ID: 35168154
No - but if you added the javascript that self-submits after the /form, it would work.

Response.Write "<form method='post' action='http://www.site.co.uk/index.php' name='myForm' id='myForm'>
<input type='hidden' name='" & theUserName &"' id='" & theIDdata "' value='" & theCandidateData "' />
<input type='hidden' id='mod_login_password' name='passwd' value='candidate' />
</form>
<!-- now send the form! -->
<script type='text/javascript'>document.myForm.submit();</script>"

Open in new window

0
 

Author Closing Comment

by:garethtnash
ID: 35745043
:)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now