Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 1991 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Hi,

I am wanting to list in a FileMaker field all the $_POST data ... I've been trying different suggestion but no luck.

$request->setField('WBForm_First_Name', $_POST['first_name']);

$request->setField('WBForm_Last_Name', $_POST['last_name']); ... 23 more.

The next $request enters the number 25 in the WBForm_Comments field ... I have 25 fields in my form.

$request->setField('WBForm_Comments', extract ($_POST));

The last step of the $request->setField I would like to list the actual data inside the $_POST to a non-editable field so the customer can look at for reference in the event they edit fields that were populated individually and needed to reference what the form had originally.

Isn't there a "Name=Value" pair for each field I am populating inside the $_POST variable ? and how can I list out the $_POST variable into a FileMaker field ?

Could anybody provide a link to somewhere or some suggestion/hint that would explain how to list out the $_POST ... I have been unsuccessful so far.

I would be grateful.

Thank you.

Mr. Ignoramus

Posted (edited)

It's impossible to answer your question with the amount of data you have provided; however your post makes me wonder: Why do you not use arrays?

Using arrays will reduce that piece of code to 3 lines, opposed to 25

<input name="s[fieldname]">
<input name="s[fieldname2]">
<input name="s[fieldname3]">
<input name="s[fieldname4]">
<input name="s[fieldname5]">
<input name="s[fieldname6]">

Then filling in the FileMaker data can be done as follows

<?php
foreach( $_POST['s'] as $k => $v ) {
	$request->setField( $k, $v );
}
?>

You may or may not want to do a conversion between the web form field name and the FileMaker one if your strategy is using obfuscation as a security measurement.

3 hours ago, "... you mean these fans?" said:

Isn't there a "Name=Value" pair for each field I am populating inside the $_POST variable ? and how can I list out the $_POST variable into a FileMaker field ?

To find out what is inside $_POST do the following

<?php
echo '<pre>';
var_dump( $_POST );
echo '</pre>';
?>

 

Edited by ggt667
Posted (edited)

For your last setField, try

foreach ($_POST as $value){
$list = $list . ',' . $value;
}
$request->setField('YourLastField', $list);

This will give you a comma-separated list of the $_POST values.  If you want a return-separated list, then convert the commas to linefeeds with an auto entered calculation in the FileMaker field.

Substitute(self; "," ; ¶)

EDIT: If your data contains commas, then use another character such as a pipe ( | ) as the separator.

Edited by doughemi
Posted

Thank you comment ... that link is working with a variable within FileMaker.  I'm inside a php script.

ggt667 - It's not impossible 

<?php
echo '<pre>';
var_dump( $_POST );
echo '</pre>';
?>

This will push the data inside the $_POST variable to the webpage ... I don't want to do that, Im entering field data into fields in FileMaker.

All I want to do after I've entered each value into each of the 25 fields is to write/list/enter whatever is in the $_POST data into ONE FileMaker field - all the data.

I am currently extracting each value inside the $_POST variable independently by doing this ....

$request->setField('WBForm_First_Name', $_POST['first_name']); ( I have 25 of these ) each to a different FileMaker field.

My final step is to consolidate all the value inside the $_POST variable into one field.  The best I can come up with is the following ...

$request->setField('WBForm_Comments', extract ($_POST)); ... but ...

I get 25 .. which is OK, but I want the values ( company name, company contact, address, phone, etc .. ) not 25 ... ?

So is there a way to pull out all the values inside the $_POST variable ? and then list them in a Field in FileMaker that I've designated.

Thank you.

Mr. Ignoramus

 

Thank you doughemi 🙂

Posted (edited)
<?php
$request->setField( 'WBForm_Comments', var_dump( $_POST ) );
?>

or if you just would like the web form field names:

<?php
unset( $tmp );
foreach( $_POST as $k => $v ) {
	$tmp[] = $k;
}
$request->setField( 'WBForm_Comments', implode( $tmp, ', ' ) );
?>

 

Edited by ggt667
Posted
4 minutes ago, "... you mean these fans?" said:

I get an error on line 46 ...

What does the error say?

Posted

$request->setField('WBFormComments', '|', $list);

That's a pipe character, shift-backslash, not a letter ell or a 1.

Posted

ggt667,

This worked ... 

$request->setField( 'WBForm_Comments', var_dump( $_POST ) );

Thank you 🙂

I will format the field within FileMaker to add the field names.

Thank you.

 

I will format the field within FileMaker to add the field names.

Thank you.

doughemi,

I copied then pasted the actual field name into that position ... it was just the curser.  

Anyway, I got it.  Thank you.

Posted

ggt667,

This does not work any more, meaning it dumps the $_POST variable to the web page, not the field ... ?  It worked once,  meaning I got the results I wanted in the field.  So I said thank you and went to bed.  What I should have done is checked it 3 times ... 😞

$request->setField( 'WBForm_Comments', var_dump( $_POST ) );

 

612150594_ScreenShot2019-05-29at8_06_04AM.thumb.png.fb25fbe24f138a9a6181917ceb68886b.png

 

I am scouring google, and reading as many tutorial as I can to try and find a way to write the $_POST variable to a field in FileMaker.

doughemi,

I'm going to retry your suggestion again ... for some reason it produced an error.

Anybody with any suggestion I would be grateful.

Thank you.

Mr. ignoramus

 

Posted

ggt667,

This is what worked .... 

    unset( $tmp );
    foreach( $_POST as $k => $v ) {
         $tmp[] = "$k: $v \n";
     }
    $request->setField( 'WBForm_Post_Var', implode( $tmp ) );

I took a guess and flipped the $k and the $v in your example above and noticed that I got the other value in the value pair, since I needed both value pairs, I googled how to put two variables together.  Thank you.

Finally got what I wanted.

I'm reading up on the unset() but still confused, why the unset() and why the $tmp ? ... and this makes no sense at the moment "$k =>$v" even after reading multiple php sources ... anyway,

$request->setField( 'WBForm_Comments', var_dump( $_POST ) );

Also, this worked only once, meaning it pushed the field values of the $_POST into the FileMaker field I designated.  But never worked afterwards ?

doughemi,

foreach ($_POST as $value){
$list = $list . ',' . $value;
}
$request->setField('YourLastField', $list);

I never could figure out why this errored, but the error was in the $list = $list line ... ?  Can't remember exactly what the php error stated ... sorry.

 

Thank you.

 

This topic is 1991 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.