...

View Full Version : checkboxes, submit values, and other stuff



conozco345
07-18-2002, 06:29 AM
ok, still working with firepages code. I am new with PHP so I need alot of help. Ok, basically what I am doing is making a whole lot of files for download, and the user decides which files they want by checking the check boxes next to the names. Then with the code given, the files will be added to one zip file and downloaded. How do I create the checkboxes, and create a submit button that then zips the file, and either starts the download automatically, or create a link on a new page?

This is basically whats happening, the zip file automatically creates itself with the preset files (file.txt).

(entire code with functions here: http://www.firepages.org/public/zipfile.php.txt)


<?php

$zipfile = new zipfile();

// add the subdirectory ... important!
$zipfile -> add_dir("dir/");

// add the binary data stored in the string 'filedata'
$filedata = implode("",file("searchtest.php"));
$zipfile -> add_file($filedata, "dir/file.txt");

// OR instead of doing that, you can write out the file to the local disk like this:
$filename = "youre_selected_files.zip";
$fd = fopen ($filename, "wb");
$out = fwrite ($fd, $zipfile -> file());
fclose ($fd);

//the next three lines force an immediate download of the zip file:
//header("Content-type: application/octet-stream");
//header("Content-disposition: attachment; filename=youre_selected_files.zip");
//echo $zipfile -> file();

// then offer it to the user to download:
echo "<a href=\"youre_selected_files.zip\">Click here to download the new zip file.</a> ";


?>

Spookster
07-20-2002, 04:27 PM
Well what you could do is take the file names submitted by the form and either store them in the files.txt file you mentioned or pass them along.

Put the coding for the zip file into a function and then pass those file names along to it or read them from the files.txt.

conozco345
07-21-2002, 07:42 AM
I have no idea how to do that... Is there anyway I could put an if statement with each checkbox, adding the file if its checked, hit a submit button and the file is created? If so what would be the code for that?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum