Danosaur Posted August 19, 2007 Share Posted August 19, 2007 My main objective is to have a list of words for a user to check via checkbox through an html code; I would like for those checked or unchecked words to be saved to a text file, spread sheet, or any document on my server. Even better would be for said information to be compiled in a paragraph separated by commas. I have been looking for upload scripts and trying to modify guestbook scripts-but I am just a newb... I would appreciate any help or suggestions! Quote Link to comment Share on other sites More sharing options...
nathanmaxsonadil Posted August 19, 2007 Share Posted August 19, 2007 you can do that easily through get Quote Link to comment Share on other sites More sharing options...
curtis_b Posted August 19, 2007 Share Posted August 19, 2007 and now for a much more useful answer: This is one way to create a comma seperated paragraph in a text file. <html><form action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST"> <input type="checkbox" name="food">food<br> <input type="checkbox" name="boxes">boxes<br> <input type="checkbox" name="computers">computers<br> <input type="checkbox" name="racecars">racecars<br> <input type="submit" value="generate file"> </form> </html> <?php //only proceed if the form has been submitted if(!$_POST)exit(); //file creation // *******in order for this to work, chmod current directory to 777 //I ended up having to chmod this php file and the name.txt file to 777, not sure //if that was entirely necessary. foreach($_POST as $key => $val){ if($data){$data .= ', ';} $data .= $key; } $ourFileName = "name.txt"; $ourFileHandle = fopen($ourFileName, 'w') or die("can't open file"); fwrite($ourFileHandle, $data); fclose($ourFileHandle); ?> Quote Link to comment Share on other sites More sharing options...
simcoweb Posted August 19, 2007 Share Posted August 19, 2007 First, create a form that has the checkbox selections. Then you'd build the query to write either to a file or database, your choice. This wouldn't be an 'upload' script. Simply gathering data and storing it. Quote Link to comment Share on other sites More sharing options...
Danosaur Posted August 19, 2007 Author Share Posted August 19, 2007 sorry for such a stupid question, but this is how everyone learns but... how do I 'chmod current directory to 777' Quote Link to comment Share on other sites More sharing options...
curtis_b Posted August 19, 2007 Share Posted August 19, 2007 chmod is how you change file/directory permissions. you can change it either through your FTP client or in a terminal/shell if you have access to the server. google chmod. In filezilla (my ftp client) I would select the directory on the server, right-click it, and select 'file attributes'. 777 is full access, that allows the php script to be able to create/overwrite files in the same directory. Quote Link to comment Share on other sites More sharing options...
curtis_b Posted August 19, 2007 Share Posted August 19, 2007 oh also, chmod assumes you're on a linux/unix server. If you're using a windows server, well, I don't know about windows permissions, but I imagine it's the same concept... you need to open up the write permissions. Quote Link to comment Share on other sites More sharing options...
Danosaur Posted August 20, 2007 Author Share Posted August 20, 2007 and now for a much more useful answer: This is one way to create a comma seperated paragraph in a text file. <html><form action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST"> <input type="checkbox" name="food">food<br> <input type="checkbox" name="boxes">boxes<br> <input type="checkbox" name="computers">computers<br> <input type="checkbox" name="racecars">racecars<br> <input type="submit" value="generate file"> </form> </html> <?php //only proceed if the form has been submitted if(!$_POST)exit(); //file creation // *******in order for this to work, chmod current directory to 777 //I ended up having to chmod this php file and the name.txt file to 777, not sure //if that was entirely necessary. foreach($_POST as $key => $val){ if($data){$data .= ', ';} $data .= $key; } $ourFileName = "name.txt"; $ourFileHandle = fopen($ourFileName, 'w') or die("can't open file"); fwrite($ourFileHandle, $data); fclose($ourFileHandle); ?> wow! huge help so far! Just some final tweaking...what line of code could I have a user input text field to be uploaded into name.txt... instead of the typical '<input type="text" name="">'? And, is it possible to create a different file on submit, or possibly have the submissions logged in the same file? Thanks for the help so far Quote Link to comment Share on other sites More sharing options...
curtis_b Posted August 20, 2007 Share Posted August 20, 2007 wow! huge help so far! Just some final tweaking...what line of code could I have a user input text field to be uploaded into name.txt... instead of the typical '<input type="text" name="">'? I'm not sure if I understand your question, why would you need to do it differently? And, is it possible to create a different file on submit, or possibly have the submissions logged in the same file? Absolutely, if you program the script to generate a unique filename (like using the current timestamp as the filename). As for logging all submissions in one file, yeah you could routinely append one text file, but at that point I would say just use a database. Quote Link to comment Share on other sites More sharing options...
Danosaur Posted August 20, 2007 Author Share Posted August 20, 2007 wow! huge help so far! Just some final tweaking...what line of code could I have a user input text field to be uploaded into name.txt... instead of the typical '<input type="text" name="">'? I'm not sure if I understand your question, why would you need to do it differently? And, is it possible to create a different file on submit, or possibly have the submissions logged in the same file? Absolutely, if you program the script to generate a unique filename (like using the current timestamp as the filename). As for logging all submissions in one file, yeah you could routinely append one text file, but at that point I would say just use a database. I am pretty much completely new to php, just so you guys understand where I am coming from. Your first quote: I would eventually like to have a custom text field in junction with the checkboxes to show up in 1 file-and I am pretty lost on how to do so. Your second quote: I've searched on google, been working on this project for about a week now (laugh if you must)...and I am pretty stuck. I think this is more then I can chew, but regardless, it needs to be finished. What is the best way to finish this project and get a decent understanding with PHP? Quote Link to comment Share on other sites More sharing options...
Danosaur Posted August 20, 2007 Author Share Posted August 20, 2007 bump Quote Link to comment Share on other sites More sharing options...
mattison Posted August 20, 2007 Share Posted August 20, 2007 Dude you can make them on front page, or google them, google allways has the answers Quote Link to comment 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.