Solved

Is there a VBScript way of doing this?

Posted on 2011-03-16
8
286 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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
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…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…

757 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

18 Experts available now in Live!

Get 1:1 Help Now