php - ColdFusion get method -


i sending value of variable http url cfm page, not sure how value on other page. in php use $_get['variable']; not sure equivalent of in coldfusion.

coldfusion has option of accessing these variables you're doing in php:

php:

$foo = $_get['variablename']; $bar = $_post['variablename']; 

cfscript:

foo = url['variablename']; bar = form['variablename']; 

cfml:

<cfset foo = url['variablename']> <cfset bar = form['variablename']> 

edit: discussion of form scope case insensitivity, , workaround

coldfusion (helpfully?) convert form fieldnames uppercase in form scope. in cases fieldname repeated, multiple values merged single comma-separated value. when don't have control on form itself, can lead frustration.

given form:

<form name="main" action="handler.cfm" method="post">   <input type="text" name="confusion" value="abc" />   <input type="text" name="confusion" value="def" />   <input type="submit" name="submit" /> </form> 

the form scope on receiving page this:

regular form scope

but can use gethttprequestdata().content directly access original form case-preserved fields , values posted:

confusion=abc&confusion=def&submit=submit

since coldfusion structs case-insensitive, can't parse string regular struct. instead can turn java.util.hashmap, coldfusion struct, preserve case:

arformscope = gethttprequestdata().content.split('&'); cs_form = createobject('java','java.util.hashmap').init(); for( i=1; i<=arraylen(arformscope); i++ ){   arelement = arformscope[i].split('=');   key = arelement[1];   value = arelement[2];   cs_form[key] = value; } 

dumping cs_form hashmap, get:

enter image description here

...and finally:

cs_form['confusion']; // def cs_form['confusion']; // abc cs_form['confusion']; // error, undefined in java.util.hashmap 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -