Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Is there a VBScript way of doing this?

Posted on 2011-03-16
8
295 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 51

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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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 …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

856 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