Solved

Is there a VBScript way of doing this?

Posted on 2011-03-16
8
292 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 50

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
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: 35161027
Not sure what you mean - the ASP is processed server side - only HTML is sent to the client.
0
 
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Questions about this React unit test 4 60
JQuery to parse xml string and get element by id 4 33
exchange ,script 10 41
Call a function within the ASP code 4 9
In this tutorial I will show you how to make a simple HTML bar chart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at http://www.experts-exchange.com/ARTH_5123186.html (http://www.experts-ex…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

808 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