karen
Posts: 99
|
Posted: 01/18/2013, 1:29 AM |
|
Hi all,
I'm trying to add 2 URL parameters in the onclick event. I can manage to add 1 URL parameter using the code like that:
global $Redirect;
$Redirect = "page.php?".CCAddParam(CCGetQueryString("Form",""), "param1", $value1);
But how do I add another URL parameter? I've tried just appending CCAddParam to that line but that repeats the whole URL parameter twice! I've looked at the documentation but I can't find anything for multiple parameters. Could be really easy but I just can't see it.
Any advice is much appreciated. Thanks!
Cheers,
Karen
CCS3.2
|
|
|
saseow
Posts: 744
|
Posted: 01/18/2013, 3:49 AM |
|
Karen, try it like this:
Just get the parts of the current param you want to keep and put them in $thequerystring and then just add params to that as below:
$Redirect = "page.php?".$thequerystring."¶m1=".$value1."¶m2=".$value2 etc. etc.
|
|
|
saseow
Posts: 744
|
Posted: 01/18/2013, 3:50 AM |
|
The &+param is being changed to &m above. I guess you can figure that out.
|
|
|
karen
Posts: 99
|
Posted: 01/18/2013, 5:14 AM |
|
Thanks so much for your quick response! And great idea! Should have thought of that. Tried it and works well. Thanks again!
|
|
|
saseow
Posts: 744
|
Posted: 01/18/2013, 7:10 AM |
|
You are very welcome and add a "Solved" to the topic?
|
|
|
DataDoIT
|
Posted: 01/18/2013, 8:15 AM |
|
Let's add a little more detail to this so folks can see how it's done...
global $FileName, $Redirect;
$QueryString = CCGetQueryString("QueryString", "");
$QueryString = CCAddParam($QueryString, "param1", "value1");
$QueryString = CCAddParam($QueryString, "param2", "value2");
$QueryString = CCRemoveParam($QueryString, "Frogger");
$Redirect = $FileName . "?" . $QueryString;
Notice how you can add and remove parameters. When adding, if the
parameter already exists, it gets overwritten.
|
|
|
karen
Posts: 99
|
Posted: 01/18/2013, 9:02 PM |
|
Thanks, have added "Solved" to title.
Just a bit more discussion on this though...
I've found that CCGetQueryString("QueryString", "") didn't work for me as it placed a cccForm parameter or something like that which made the browser loop endlessly. So I had to use CCGetQueryString("Form", "") instead. I know according to the documentation, "QueryString" is for GET parameters and "Form" is for POST. The only difference I noticed is with the GET parameters, I get ccsForm parameter and POST, I get Button_doSearch parameter. All the other input parameters are the same.
Can someone please explain/advise. I think I really should be using GET parameters ("QueryString" option).
Cheers,
Karen
|
|
|
MichaelMcDonald
Posts: 640
|
Posted: 01/18/2013, 9:28 PM |
|
If you want to GET variables from the page you can :
$param = CCGetFromGet("param"); $param1 = CCGetFromGet("param1"); $Redirect = "pagename.php" . "?param=" . $param . "¶m2=" . $param2 . "¶m3=" . $param3;
on the second and susequent parameters use "&" instead of "?"
_________________
Central Coast, NSW, Australia.
|
|
|
karen
Posts: 99
|
Posted: 01/18/2013, 10:18 PM |
|
Thanks for all the advice. I've checked again and this time "QueryString" option seems to be good; not sure what I did before :P
I was going to use the tip on removing parameters to fix it but now I don't have to. All's working fine again. Thanks much!
|
|
|
DataDoIT
|
Posted: 01/21/2013, 3:20 PM |
|
As a safe practice, whenever working with the QueryString, I will always:
$QueryString = CCRemoveParam($QueryString, "ccsForm");
|
|
|
karen
Posts: 99
|
Posted: 01/21/2013, 11:07 PM |
|
Yes, I've read about this parameter and security. But not sure what it does. So if you don't mind, please do explain the idea behind this. Thanks!
|
|
|
DataDoIT
|
Posted: 01/22/2013, 8:33 AM |
|
The ccsForm URL parameter is the trigger that CodeCharge uses to process
the form. So if you don't want to actually process the form, then
remove the parameter.
An example usage case would be using a form to be able to use buttons
and their respective button actions such as OnClick. A dummy form if
you will.
This is why for every single form you have in your application (that
includes editable grids) you should have some form of validation to
prevent injection bots from pounding on your door.
|
|
|