Re: Testing checkbox settings
Posted: Sun Jul 17, 2011 1:17 pm
Can you link to the actual URL so I can try it myself? You can PM it to me if you want.
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Okay, try removing the two header()s at the beginning of filter.php. Looks like those are messing things up.giomach wrote:Sorry I didn't see your message until now.
The url is: --removed--
Remember the problem: trying to send control to filter.php when the submit button (labelled "Anuas") is pressed, but filter.php takes three parameters, of which only the first is known in advance. The other two should take their values from the checkboxes.
Thanks yet again,
Giomach.
In case it helps:
Here is the whole of download2.php:
and here is the start of filter.php:Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> </head> <body> <table> <tr> <td width="475"></td> <td width="175"></td> <td width="100"></td> </tr> <tr><form method="get" action="http://www.smo.uhi.ac.uk/~oduibhin/phptest/filter.php?fng_file=Lu054_utf8.txt"> <td>Text in column one</td> <td><input type="checkbox" value="2" name="fng_ceart"> box one<br /> <input type="checkbox" value="2" name="fng_marc"> box two<br /> </td> <td align="center"><input type="submit" name="formSubmit" value="Anuas" /></td> </form></tr> </table> </body> </html>
GiomachCode: Select all
<?php header ("Content-type: text/plain; charset=utf-8"); header ('Content-disposition: filename='.$_GET ['fng_file']); $marcailte = $_GET ['fng_marc']; // $marcailte = 3; // echo "###".$marcailte."###"\n; $ceartaithe = $_GET['fng_ceart']; // $ceartaithe = 2; // echo "$$$".$ceartaithe."$$$"\n; $infile = "http://www.smo.uhi.ac.uk/~oduibhin/phptest/".$_GET ['fng_file']; // echo $infile."#".$marcailte."#".$ceartaithe; // $infile = "input.txt"; // echo "£££".$infile."£££"\n; $lines = file ($infile); if ($marcailte == 2) $ceartaithe = 1; // echo $ceartaithe.'#'.$marcailte;
Code: Select all
isset ($HTTP_GET_VARS)Code: Select all
<?php
print_r($_GET);
?>Array ( [formSubmit] => Anuas )...place this:
<?php
print_r($_GET);
?>
Code: Select all
<html>
<body>
<form method="get" action="http://.../filter.php?fng_file=Lu054_utf8.txt">
<input type="checkbox" value="2" name="fng_ceart"> box one<br />
<input type="checkbox" value="2" name="fng_marc"> box two<br />
<input type="submit" name="formSubmit" value="Anuas" />
</form>
</body>
</html>Code: Select all
<input type="hidden" name="fng_file" value="Lu054_utf8.txt" />.. or tested they weren't set!If you don't check the checkboxes, they won't be sent at all. Did you make sure you checked them?
Two vital pieces of information, which proved to be what I needed. They weren't particularly well explained in the textbooks I used. (And not explained at all was the fact, which I gathered earlier in the discussion, that defining an INPUT field sets $_GET ['name'] (at least when action="get"), that this is accessible in any PHP script, and that the same field name can be used in different forms without confusion.)If you want to pass a known parameter in a form, add it as a hidden input, like so: