Solved

Direct URL Form

Posted on 2001-09-17
27
571 Views
Last Modified: 2013-12-24
at the URL: http://www.server.edu/path/to/coldfusionProgram.cfm

in the page source is the following:

<FORM ACTION="#url#" METHOD=Post>
 <Input Type=Text NAME=USERNAME>
 <Input Type=Password NAME=PASSWORD>
 <Input Type=Text NAME=STARTDATE>
 <Input Type=Text NAME=ENDDATE>
</FORM>

What I am trying to do is access this information via ONE URL. I have tried:
http://www.server.edu/path/to/coldfusionProgram.cfm#url#?USERNAME=abc123&PASSWORD=secret&STARTDATE=01/01/1999&ENDDATE=05/30/2002

but this does not work. I get the SAME html page as is on http://www.server.edu/path/to/coldfusionProgram.cfm. What I want is the infromation that I have passed to the form via a single url so I don't have to goto the initial page.

Help!!
0
Comment
Question by:rw263
  • 11
  • 9
  • 5
  • +1
27 Comments
 
LVL 2

Expert Comment

by:hanj
Comment Utility
hello...
i think i know what you're trying to do...

<cfset myURL = "http://www.server.edu/path/to/coldfusionProgram.cfm">
<cfform action="#myURL#" method="post">
<Input Type=Text NAME=USERNAME>
<Input Type=Password NAME=PASSWORD>
<Input Type=Text NAME=STARTDATE>
<Input Type=Text NAME=ENDDATE>
<input type="submit" value="Enter">
</cfform>

This should go to http://www.server.edu/path/to/coldfusionProgram.cfm and carry the following form variables?
form.username, form.password, form.startDate, form.EndDate.

The coldfusionProgram.cfm should be looking for these variaables.

I hope this helps
Thanks
hanj

0
 

Author Comment

by:rw263
Comment Utility
I am not looking to write html, I am looking for a single url that I can use to pass the information into the script.

For example, on CGI pages the below URL works:
 http://www.server.edu/cgi-bin/program.cgi?user=acb123&pwd=test

but for some reason, cold fusion doesn't like:
http://www.server.edu/path/to/coldfusionProgram.cfm#url#?USERNAME=abc123&PASSWORD=secret&STARTDATE=01/01/1999&ENDDATE=05/30/2002

What is the URL I can use to access the information from the form.

Is this any clearer? HELP!!
0
 
LVL 2

Expert Comment

by:hanj
Comment Utility
Your form variables are contained in the form.variable scope.  Your URL should just point to http://www.server.edu/path/to/coldfusionProgram.cfm

the coldfusionProgram.cfm should be looking for form variables.

coldFusionProgram.cfm

<cfif IsDefined(form.UserName)>
Do this
<cfelse>
Do something else
</cfif>

You should remove the querystring and the #URL# variable.  It does not make sense... that is why ColdFUsion is complaining.  Your querystring data is already in the form.

I hope this helps
hanj



0
 
LVL 19

Expert Comment

by:cheekycj
Comment Utility
Do this:
<FORM ACTION="#CGI.Script_Name#" METHOD=Post>
<Input Type=Text NAME=USERNAME>
<Input Type=Password NAME=PASSWORD>
<Input Type=Text NAME=STARTDATE>
<Input Type=Text NAME=ENDDATE>
</FORM>
0
 
LVL 19

Expert Comment

by:cheekycj
Comment Utility
if you want the query string too do this:
<FORM ACTION="#CGI.Script_Name#?#CGI.Query_String#" METHOD=Post>
<Input Type=Text NAME=USERNAME>
<Input Type=Password NAME=PASSWORD>
<Input Type=Text NAME=STARTDATE>
<Input Type=Text NAME=ENDDATE>
</FORM>
0
 

Author Comment

by:rw263
Comment Utility
I think everyone is misunderstanding what I am trying to do. I am looking for a SINGLE URL that I can use to pass the variable information from the form, without calling the URL for the form directly. I am not interested in the HTML code, I am looking to pass all the information into a Cold Fusion form directly form the URL so as to not fill out any form information via the online form, just passing all the variables via the URL. Does this make it clearer?
0
 
LVL 2

Expert Comment

by:hanj
Comment Utility
0
 
LVL 19

Expert Comment

by:cheekycj
Comment Utility
OK.. can you explain it step by step.

Could you answer these questions:

What is the value of #url#?
Do you want the page to submit to itself?
Do you want the form info the be accessible via the URL after it has been submitted?
Do you want to prepopulate the form using the URL params?

You state you want the form vars in the URL.. how so.. after it is submitted?  If that is the case use GET instead of POST.  If that is not the case.. how do you want the URL params to be populated with the form fields.. i.e.  what action is to take place..

I am not sure if I am following exactly what you need but if you can outline it clearly I am sure someone here can help you accomplish what you need.

CJ
0
 

Author Comment

by:rw263
Comment Utility
CJ --

I am not looking to edit the HTML at all.

A CGI script can be called by sending the value of the parameter names via a single URL. Within the URL is the CGI script location as well as the values that you designate for the parameter names you list.

This single URL appears to not work on a cold fusion script whereas it does for a CGI script.

My question (once again), how do I via ONE URL specificy the values and parameter names such that the information will be passed via ONE URL to the form which takes the parameters that the URL designated.
0
 

Author Comment

by:rw263
Comment Utility
Let me ty to re-explain what I am trying to do:

or a cgi script, one can pass values into a parameter directly from the URL for example:
 http://patch/to/program.cgi?param1=value1&param2=value2

However when I try to do a similiar URL for a coldfusion script it doesn't work:
 http://patch/to/program.cfm?param1=value1&param2=value2

for some reason this doesn't pass the parameters/values into progam.cfm. What is the URL that I can use to pass this information directly to the script?
0
 
LVL 2

Expert Comment

by:sshhz
Comment Utility
rw263,

I hope i catch what you are trying to say. These are the codes, pls try that. So, i use index.cfm, to allow user to enter the username, password, startdate and enddate. Then it passes to the temp.cfm. This temp.cfm will pass all these form fields into a URL parameter passing. Is this what you are looking for ? Good Luck.

<!--- enter user particulars (index.cfm) --->
<FORM ACTION="temp.cfm" METHOD=Post>
<Input Type=Text NAME=USERNAME>
<Input Type=Password NAME=PASSWORD>
<Input Type=Text NAME=STARTDATE>
<Input Type=Text NAME=ENDDATE>
</FORM>
<!--- end of enter user particulars --->


<!--- temp.cfm --->
<cfset urladd = "http://www.server.edu/path/to/coldfusionProgram.cfm">

<cfset myurlparameter = USERNAME=#URLEncodedFormat(FORM.USERNAME)#&PASSWORD=#URLEncodedFormat(FORM.PASSWORD)#&STARTDATE=#URLEncodedFormat(STARTDATE)&ENDDATE=#URLEncodedFormat(ENDDATE)#>
<cflocation url="#urladd#?#myurlparameter#">

<!--- end of temp.cfm --->

sshhz
0
 

Author Comment

by:rw263
Comment Utility
sshhz --

I am not looking to write html/cfm pages!

What I would like to do is pass the parameter/values directly to the cfm via a single url.

Not sure how else to explain it.
0
 

Author Comment

by:rw263
Comment Utility
sshhz --

I am not looking to write html/cfm pages!

What I would like to do is pass the parameter/values directly to the cfm via a single url.

Not sure how else to explain it.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 2

Expert Comment

by:hanj
Comment Utility
http://patch/to/program.cfm?param1=value1&m2=value2

when you are trying to goto this URL, what error message do you receive from Cold Fusion???

hanj
0
 
LVL 2

Expert Comment

by:hanj
Comment Utility
http://patch/to/program.cfm?param1=value1&m2=value2

when you are trying to goto this URL, what error message do you receive from Cold Fusion???

hanj
0
 
LVL 2

Expert Comment

by:sshhz
Comment Utility
rw263,

Okay, u don't want any codings ... all you need is just url passing. Hmm, i wonder how it could be done, thought of suggesting you with javascript since you mentioned NO CODES, err .... ?? *scratch my head too*

sshhz
0
 

Author Comment

by:rw263
Comment Utility
hani --

When I pass try: program.cfm?param1=value1&m2=value2, program.cfm simply loads without any variables passed, it is as if the question mark and everything aftwords weren't typed in.


sshhz --

The problem is I am a user of the system, I have no access to edit/modify the .cfm file.
0
 
LVL 19

Expert Comment

by:cheekycj
Comment Utility
Well the problem is this:

Whoever wrote the .cfm file probably intended the program.cfm to take FORM post variables.

Unfortunately ColdFusion handles POST variables differently then GET variables.

POST variables are handled by FORM.varname
GET variables (or URL parameters) are handled by URL.varname

so if program.cfm is written to accept POST vars thus it must be using FORM.varname then when you send the variables via the URL (or a get form method) then it cannot access the vars.. because it believe the vars are coming through FORM.*  whereas you are sending them as URL.*

The code must be updated in program.cfm to convert all URL parameters to FORM parameters.. I have a script that does that for you (I can post it here if you want) but the program.cfm MUST be modified to accept both POST And GET methods (URL parameters)

I am sure that is NOT what you want to hear.. but unfortunately its a quark with CF.  I ran into this problem when I converted a site from form method type POST to GET and had to create this utility that converted all URL vars to FORM vars to get any of the existing code to work.

CJ
0
 

Author Comment

by:rw263
Comment Utility
cheekycj  --

AH GREAT!, you seem to know quite a bit about CF! I have read your post and understand exactly what you mean. I can think of a work around, but I am not sure how to implement it. What if..... I do a direct URL call to a form page which redirects the parameters/values to the .cfm page.

Any thoughts on how to do that?
0
 
LVL 19

Expert Comment

by:cheekycj
Comment Utility
I can create a page that will take URL parameters.. and post to the program.cfm for you and display the results.

Is that what are you thinking of as an alternative?

CJ
0
 

Author Comment

by:rw263
Comment Utility
cheekycj  --

Exactly!
0
 
LVL 19

Expert Comment

by:cheekycj
Comment Utility
OK.. I will work on that.. I will post code shortly...

CJ
0
 
LVL 19

Expert Comment

by:cheekycj
Comment Utility
OK.

Here is the code:
<!--- Begin Code --->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
     <title>URL FORM POST TEST</title>
</head>

<body>
<CFIF CGI.Query_String EQ "">
  You must pass some URL parameters to use this file
<CFELSE>
<CFHTTP URL="http://www.yourserver.com/pathtoprogram/program.cfm" METHOD="POST" RESOLVEURL="false">
<!--- process GET params into POST params (URL. to FORM.) --->
<CFLOOP INDEX="formdata" LIST="#CGI.Query_String#" DELIMITERS="&">
     <cfif ListLen("#formdata#","=") GT 0>
          <cfif ListLen("#formdata#","=") EQ 1>
               <CFSET name = ListGetAt("#formdata#", 1 ,"=")>
               <cfset value = "">
          <cfelse>
               <CFSET name = ListGetAt("#formdata#", 1 ,"=")>
               <cfset value = ListGetAt("#formdata#", 2 ,"=")>
          </cfif>
     </CFIF>
  <CFHTTPPARAM TYPE="FORMFIELD" NAME="#name#" VALUE="#URLDecode(value)#">
</CFLOOP>
</CFHTTP>
<HR>
Results from posting (HTML Returned):
<HR>
<CFOUTPUT>#CFHTTP.FileContent#</CFOUTPUT>
</CFIF>
<HR>
Done.
</body>
</html>
<!--- End Code --->

Directions:
First update the URL http://www.yourserver.com/pathtoprogram/program.cfm to whatever FULL URL PATH (including the http://) to your program.cfm

This needs to be put on a server that is running Coldfusion as whatever filename you want.

Run it using
http://serverrunningthishttpcode/fileyousaveditas.cfm?urlparam1=val1&urlparam2=val2

HTH,
CJ

When
0
 

Author Comment

by:rw263
Comment Utility
cheekycj  --

I can't make any changes to the program.cfm file as it is not mine, I am just a user of the system. As for the code, I don't have access for coldfusion, but a simple html page would do it?
0
 
LVL 19

Expert Comment

by:cheekycj
Comment Utility
To actually simulate a POST to program.cfm.. you need ColdFusion.

The other way I can think of automating this is using javascript.  I can try to whip up a JavaScript version of the above for you.

Is Program.cfm actually process the data or is the form itself.

Can you post the form (html code for it) so I know what to expect as URL params.

CJ
0
 

Author Comment

by:rw263
Comment Utility
The "important" parts of the html/form are posted in the original help question that I opened the topic with <Form>....</Form>
0
 
LVL 19

Accepted Solution

by:
cheekycj earned 200 total points
Comment Utility
OK here is the HTML (using JavaScript) version:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
     <title>FORM Submission</title>
</head>
<body>
<FORM ACTION="Form_action.cfm" METHOD="Post" NAME="programForm">
<Input Type="hidden" NAME="USERNAME" VALUE="">
<Input Type="hidden" NAME="PASSWORD" VALUE="">
<Input Type="hidden" NAME="STARTDATE" VALUE="">
<Input Type="hidden" NAME="ENDDATE" VALUE="">
</FORM>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
function getArgs() {
     var args = new Object();
     var query = location.search.substring(1).toLowerCase();
     var pairs = query.split("&");
     for(var i = 0; i < pairs.length; i++) {
         var pair=pairs[i].split("=");
        var argname = pair[0]
        var value = pair[1]
        args[argname] = unescape(value);
     }
     return args;
}
var args = getArgs();
var requiredFields = 0;

for (var key in args) {
  if (key == "username") {
    document.programForm.USERNAME.value = args[key];
    requiredFields++;
  }
  else if (key == "password") {
    document.programForm.PASSWORD.value = args[key];
    requiredFields++;
  }
  else if (key == "startdate") {
    document.programForm.STARTDATE.value = args[key];
    requiredFields++;
  }
  else if (key == "enddate") {
    document.programForm.ENDDATE.value = args[key];
    requiredFields++;
  }
}
  if (requiredFields == 4)
    document.programForm.submit();
  else
    alert("You Have to Provide all 4 required fields as URL parameters");
</SCRIPT>
</body>
</html>

save this file as a HTML file.. put it on a SERVER preferabbly though I think It may work off a desktop too.

You must pass the following URL parameters
username
password
startdate
enddate

to use the file.

EDIT the form action=" ...." part to the FULL URL (including http://) to PROGRAM.cfm

CJ
0

Featured Post

What Security Threats Are You Missing?

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

Suggested Solutions

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 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

7 Experts available now in Live!

Get 1:1 Help Now