Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Is there a VBScript way of doing this?

Posted on 2011-03-16
8
Medium Priority
?
300 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 54

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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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 2000 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 Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
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 …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

783 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