CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 request for help with converting a POST array into a text box before sql insert

Print topic Send  topic

Author Message
whiterabbitwond

Posts: 28
Posted: 10/29/2009, 3:44 PM

Hello!

Problem:
I am posting data to a CCS record form from another application (surveygizmo.com).
In their survey system, they allow the survey data to be posted to an external form. They post checkbox fields as an array.
When I post checkbox data to my CCS form, it only grabs the first value in the array.
Up to now, i have been converting the checkbox questions in gizmo with implode() and setting to a text field BEFORE the post so it would be received by the CCS form nicely as a string.
This is painfully tedious to hand code each checkbox implode, as I program a lot of surveys, and the checkbox array values change from survey to survey.

Request:
I would like to somehow have the CCS form recognize an incoming array in the POST, and implode it automatically into the text box/db field it was destined for. Honestly I have no idea how to preprocess post data in CCS with php, or even how to ask this question in such a way to google any answers. Any assistance would be much appreciated.

Thank you!

David
View profile  Send private message
whiterabbitwond

Posts: 28
Posted: 11/03/2009, 1:18 PM

Bump. Anyone? If necessary I can compensate anyone who can assist with a solution via paypal.
Are you a developer who knows how to code this?
Thanks a bunch in advance,
david
View profile  Send private message
Gena

Posts: 591
Posted: 11/03/2009, 1:31 PM

Check for function CCGetRequestParam();

it works like
$larg = CCGetRequestParam("larg", ccsPost, "");

_________________
Gena
View profile  Send private message
whiterabbitwond

Posts: 28
Posted: 11/03/2009, 1:56 PM

Thanks. I could not find that function. Only found CCGetParam or CCGetFromPost.
That does not get me closer though.
View profile  Send private message
Gena

Posts: 591
Posted: 11/04/2009, 2:26 AM

This function is located in common.php file

function CCGetRequestParam($ParameterName, $Method, $DefaultValue = "")  
{  
    $ParameterValue = $DefaultValue;  
    if($Method == ccsGet && isset($_GET[$ParameterName]))  
        $ParameterValue = CCStrip($_GET[$ParameterName]);  
    else if($Method == ccsPost && isset($_POST[$ParameterName]))  
        $ParameterValue = CCStrip($_POST[$ParameterName]);  
    return $ParameterValue;  
}

_________________
Gena
View profile  Send private message
whiterabbitwond

Posts: 28
Posted: 11/04/2009, 10:25 AM

Thanks a bunch. I should mention that the reason i use CCS is because while i am have strong sql skills, my php / interface skills are pretty much null.
I sort of understand what is happening in the code you quoted.

I think what i'm looking for, is a custom function that *on this specific page only* takes any arrays posted and implodes them in to key/value pairs that will fit nicely in a text box. I say this page only as I still want all my other normal php pages to deal with the arrays normally.

The arrays' key / values will almost always be different, so they can't match any sort of checkbox fields on the ccs page. it just needs to take the arrays and make them as though someone had typed "key:value; key:value; key:value" into a text box and hit submit.

Gena, would you be able to create a custom function like this? Please let me know if / how much you would like me to donate. I could afford something less than $50 for this. I would also need to know how / where to put it.

Thank you,

David
View profile  Send private message
Gena

Posts: 591
Posted: 11/04/2009, 12:35 PM

I'm not sure why you need to type "key:value; key:value; key:value" into a text box and hit submit. Why just don't get POST values and put it directly into DB???

  
$vals ='';  
foreach ($_POST as $key => $value){  
    $vals .= $key . ":" .$value .";";  
}

_________________
Gena
View profile  Send private message
whiterabbitwond

Posts: 28
Posted: 11/05/2009, 6:03 PM

The way I built this, was with a Record form on a CCS page. It has a bunch of text boxes. I set up surveygizmo to post the survey answers (form values) to this page (fooling ccs into thinking i had typed the values myself).

Except that surveygizmo submits its checkbox answers as arrays, that i have to translate into a single text field. Up to now i have handled this in surveygizmo, except it is tedious to implode() each checkbox array.

surveygizmo: question: "what magazines do you read" answer: vogue, seventeen

when posting, data for that question's answer would look like this: "Array ( [O1] => vogue [O2] => seventeen)"

and since it is posting to a text box, ccs only receives the first value and not the rest. ***I just need it to receive all the values from the array. (i made a mistake in last post, i just need the values, not the keys from the array).

Thank you for the code you posted, although i don't know where or how to implement this on my page. Can you elaborate?

Thank you,

David
View profile  Send private message
whiterabbitwond

Posts: 28
Posted: 01/18/2010, 4:17 PM

I wonder if anyone might be able to assist me further with this. I'm afraid my raw php coding skills are not super.
Thank you in advance
David
View profile  Send private message
datadoit
Posted: 01/18/2010, 6:20 PM

You could change the CCS field's value in the OnValidate event. So for
your textbox OnValidate event, add custom code similar to what Gena
suggested:

$vals = "";
foreach ($_POST as $key => $value) {
$vals .= $value . ", ";
}

$Component->SetValue($vals);

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.