Creating a unique named CSV in Form...

User 2355459 Photo


Registered User
7 posts

Trying to modify code in form.cfg.php to allow a unique named csv.
I'm creating a variable based on date & ip ($filen)
Need to replace the code "filename" : "xxx.csv",
with "filename" : $filen,
Any ideas, Thanks

<?php
$stamp = date("Ymdhis");
$ip = $_SERVER['REMOTE_ADDR'];
$orderid = "$stamp-$ip";
$orderid = str_replace(".", "", "$orderid");
$ext = ".csv";
$filen = "$orderid$ext";
?>
<?php exit(0); ?> {
"settings":
{
"data_settings" :
{
"save_file" :
{
"filename" : "xxx.csv",
"is_present" : true
},
User 187934 Photo


Senior Advisor
20,190 posts

When you setup the form it should give a unique name to the csv.:)
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2355459 Photo


Registered User
7 posts

You can name the .csv file within the form and each submit appends the .csv.
I want a new .csv for each submit. Thanks
User 187934 Photo


Senior Advisor
20,190 posts

How are you using the data that you need a different named csv?:)
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 464893 Photo


Ambassador
1,611 posts

I agree Eric it does seem a strange request as with php you can get the last entry with this script. One I created for one task I had to do. It finds the last entry then a chosen item from the record.

<?php
error_reporting(E_ALL & ~E_NOTICE);
$file_handle = fopen("http://path/results.csv", "r");// the address where the file is located
while (!feof($file_handle)){
$item = fgetcsv($file_handle, 1024);
if($item=="")Break;// make sure the last entry is used
$lastitem=$item;
}
fclose($file_handle);
$option= $lastitem[0]; //note the number is the position of the data you want
?>


Alternately you could use a database and have an easier choice of selecting what you want
The Guy from OZ



Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.