Closed Thread Icon

Topic awaiting preservation: Access send data/PHP (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=12789" title="Pages that link to Topic awaiting preservation: Access send data/PHP (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Access send data/PHP <span class="small">(Page 1 of 1)</span>\

 
u-neek
Bipolar (III) Inmate

From: Berlin, Germany
Insane since: Jan 2001

posted posted 06-16-2003 10:55

This is my form:
<form name="deleteThese" method="post" action="myphpfile.php">
<input type="hidden" name="process" value="5" />
<input type="checkbox" name="install.txt" />install.txt<br />
<input type="checkbox" name="license.txt" />license.txt<br />
<input type="checkbox" name="warranty.txt" />warranty.txt<br />
</form>

I want to delete all checked files. My PHP source (part of it):

$dir = opendir($path);

while ($file_name = readdir($dir)) {
If ((is_writable($file_name)) && ($file_name <> $thisFile)) echo ("<input type=\"checkbox\" name=\"". $file_name ."\" />". $file_name ."<br />\n");
echo $_POST[$file_name];
}
closedir($dir);

But $_POST[$file_name]; is emtpy.

What did i wrong?

[This message has been edited by u-neek (edited 06-16-2003).]

Trigger
Paranoid (IV) Inmate

From:
Insane since: Jun 2002

posted posted 06-16-2003 12:42

I can only asue, that you use $_POST['file_name'] at one point and the bn before it you just use $file_name for your while statement..

prehaps you should change the other vars to $_POST['file_name']
or declare
$file_name = $_POST['file_name'];

Trigger

u-neek
Bipolar (III) Inmate

From: Berlin, Germany
Insane since: Jan 2001

posted posted 06-16-2003 13:55

Thanks, i found my mistake. But couldn't solve the main problem.
I changed my form:

<input type="checkbox" name="deleteFile" value="install.txt" />install.txt<br />
<input type="checkbox" name="deleteFile" value ="license.txt" />license.txt<br />
<input type="checkbox" name="deleteFile" value ="warranty.txt" />warranty.txt<br />

Now i can access $_POST["deleteFile"]. But only the last value. How can i access all 2 or 3 filenames?

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

posted posted 06-16-2003 16:15

u-neek: Have a look here:

:FAQ: How do I pass data from checkboxes in a form using PHP?

Also you'd better make sure there is nothing else in there which you want deleting in that folder as someone could have fun with that script

___________________
Emps

FAQs: Emperor

butcher
Paranoid (IV) Inmate

From: New Jersey, USA
Insane since: Oct 2000

posted posted 06-16-2003 19:51

u-neek

I was just getting ready to type out a post, but luckily I checked Emps link first because that's exactly what I was going to suggest.

If you name your checkboxes in that manner (name="checkbox[]") you can then loop through it in your code as an array:

foreach ($_POST['checkbox'] as $value) {

//do your stuff here
}

-Butcher-

Bmud
Bipolar (III) Inmate

From: Raleigh, NC
Insane since: Mar 2001

posted posted 04-09-2004 22:44

*finds this old post helpful*
Thankyou Emps. The FAQ prevails once more.

Shine and shine. :: [Cell=992] :: [See my team's 30 second animation]

« BackwardsOnwards »

Show Forum Drop Down Menu