squishypentagon Posted May 9, 2011 Share Posted May 9, 2011 Ok, I have tried using the code from this link http://answers.yahoo.com/question/index?qid=20100927173625AAmEmiW <?php // Get the name they entered in the form // We'll be naming the file this $file = $_POST['name']; // Get the email from the form $email = $_POST['email']; // We want the file to be a text file right? $ex = ".txt"; // Try to open a file named $file$ex (johndoe.txt for example) // Because this file doesn't exist yet the server creates it $write = fopen("$file$ex","w"); // Now open the file up again but this time save the email in it fwrite($write,$email); // MAKE SURE you close the file!!! fclose($write); // The folder that this script is in on the server is where the file we just made was saved // We can 'rename' it to another folder // The folder on the server we want to move it to $data = "../emails/"; // Now put it all together: This example goes out of the folder we're in and into the folder 'emails' // The new 'name' would be this now (../emails/johndoe.txt): So now the file is moved to where we want for storage rename ("$file","$data$file$ex"); // The script is done, send the user to another page (Just read the address below and you'll get it) exit; ?> unfortunately it doesn't do as i would like. I'm not sure how to get it to save a new file based on a variable on the form page or from one of the fields in the form. What i need is a way for a user to submit the form and it save the data into a uniquely named csv file. I know the code given is for text files, not csv, but that was about all i could find. If there is any help i would greatly appreciate it. Quote Link to comment https://forums.phpfreaks.com/topic/235923-sending-form-data-to-csv-file/ Share on other sites More sharing options...
squishypentagon Posted May 10, 2011 Author Share Posted May 10, 2011 I'm going to guess that with the amount of views and the lack of response means no one knows what to do. Quote Link to comment https://forums.phpfreaks.com/topic/235923-sending-form-data-to-csv-file/#findComment-1213157 Share on other sites More sharing options...
fugix Posted May 10, 2011 Share Posted May 10, 2011 do you receive any errors when this is tested? Quote Link to comment https://forums.phpfreaks.com/topic/235923-sending-form-data-to-csv-file/#findComment-1213160 Share on other sites More sharing options...
xyph Posted May 10, 2011 Share Posted May 10, 2011 This is a forum for help with original code. If it's someone else's script, I suggest getting support from them. The code posted above is very dangerous, and will allow someone to mess with files you might not want them to. $_POST['name'] = '../../some/other/folder/file'; Quote Link to comment https://forums.phpfreaks.com/topic/235923-sending-form-data-to-csv-file/#findComment-1213164 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.