Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pass values from ASP to CGI

Status
Not open for further replies.

craigward

Programmer
Nov 13, 2007
230
GB
Hi,

I have been asked to pass data to a .CGI page. The data will be passed from my .asp page and they want me to pass the data in a querystring.

I have used ASP for years and can pass data from page to page and into database so i am familiar with that but only when a user clicks a button. Not in a script that is passed to from a client site.

They send a request to my .asp page using a querysting containing the some values. My code then checks the database using the values they passed and has to pass values back to the following url (below is a dummy url).

Question is, if no one is clicking a button as this page just sits on my server, how do I execute the url? Is there a function in ASP that says pass to the URL and don't load a page up or do I need .NET?

Any help would be great. Thanks
 
Correct me if I'm wrong, but are you trying to execute a CGI script in the background without re-loading the page? If so, when do you want it to execute?

You can use Javascript, but before I elaborate, I just want to ensure that's what you are acheiving.



TIP: trying googling the answer before posting, you'll find that more times than not someone else somewhere has had the same request and posted an answer online.
----
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javascript enabled browsers
 
Hi Thanks for your reply. I am not to sure about cgi, i think it means an application that passes data, if so then yes you are right.

My asp code will be executed when link passed by another source, not sure from what language. My code will run and if something is true i need my code to execute a url.

Here is an example, i will be adding lot's more to it but in the if statement i need to pass values from the database that i will embed in the url.

Code:
<!--#include file="includes/connection.asp"-->
<%
	SenderMobileNumber = Request.QueryString("SenderMobileNumber")
	MessageText = Request.QueryString("MessageText")
	
	qryCheckNumber = "SELECT SenderMobileNumber FROM icetrack WHERE SenderMobileNumber = '"& SenderMobileNumber &"'"
	Set oRsSelect = connStr.Execute(qryCheckNumber)
	
	Do While Not oRsSelect.eof
	
		SenderMobileNumberChecked = oRsSelect("SenderMobileNumber")
	
	oRsSelect.MoveNext
	Loop	

	
	If SenderMobileNumberChecked <> "" Then
		'response.write(oRsSelect

	'THIS IS WHAT I NEED TO PASS IF MY CODE IS TRUE
	[URL unfurl="true"]www.test.com/submitmsg.cgi?usermane=john&msg=test[/URL]	
	Else
	
		
	
	End If

%>

Thanks for this help.
 
If all you are doing is loading the CGI URL then this might do the trick:
Code:
<% if condition true then %>
<script language="javascript">
document.getElementById("username").value = "John";
document.getElementById("msg").value = "Test";
document.getElementById("myForm").submit();
</script>
<% end if %>

<form method="get" action="[URL unfurl="true"]http://www.text.com/submitmsg.cgi"[/URL] style="display:none" id="myForm">
<input type="text" name="username" id="username" />
<input type="text" name="msg" id="msg" />
</form>

You can replace the hardcode values of "John" and "Test" with asp vars (document.getElementById("username").value = "<%=myValue%>"; Note: The Javascript must reside outside of the asp code block (<%%>)



TIP: trying googling the answer before posting, you'll find that more times than not someone else somewhere has had the same request and posted an answer online.
----
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javascript enabled browsers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top