• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: How to write specific field data to a file

How to write specific field data to a file 8 years 8 months ago #35606

  • nico
  • nico's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 5
Hi there,

Please help me to create a file after a submission.

I found the following code to write all data to a file:
// This is the path where we will store the data.
$file = JPATH_SITE.'/tmp/test.txt';
 
// You can make it unique by uncommenting the below line (ie. remove //)
// $file = JPATH_SITE.'/tmp/'.uniqid('test').'.txt';
 
// Initialize an empty $data string. This will hold our processed data.
$data = '';
 
// Loop through all of the submitted data and add it to $data.
foreach ($_POST['form'] as $name => $value) {
  // If it's a multiple selection (eg. checkbox, dropdown) we'll have to separate the values by a comma.
  if (is_array($value)) {
    $value = implode(', ', $value);
  }
 
  // Write the name and value pair (eg. First Name=Jack) to $data
  $data .= "$name=$value\r\n";
}
 
// Now, store $data in the $file.
file_put_contents($file, $data, FILE_APPEND | LOCK_EX);
 
// This is specific to RSForm! Pro - $adminEmail['files'] contains a list (an array) of all of the files that will be attached to the email.
   $adminEmail['files'][] = $file;
// You can also use $userEmail in the same way, if you're using this script for the User Email.
// $userEmail['files'][] = $file;

How do I (non-programmer ;-) change this code to write specific field data in a specific order?

I guess I have to skip the 'foreach' part.

But, how do I change: $data .= "$name=$value\r\n";
to add field values to $data
to get a file like:
support_code
first_name
last_name
etc.

What is the syntax to add a field value to the var $data ?

Is there anyone who is willing to help this amateur ;)
Thank you very very much for a reply.

Best regards, Nico
Last Edit: 8 years 8 months ago by nico.
The administrator has disabled public write access.

How to write specific field data to a file 8 years 8 months ago #35616

  • nico
  • nico's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 5
Is there someone willing to help me to let me know what the PHP syntax is to add RSFormPro field-values to a VAR?

This because I like to create a file that will contain some (not all) data from the form in a specific (other than in the form) order. That file will be a import file for a different app.

A tip or hint will help me a lot! Thank your very much.
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!