PHP forms.
Moderator: General Moderators
-
Simon Angell
- Forum Commoner
- Posts: 45
- Joined: Fri Jan 24, 2003 12:14 am
-
Simon Angell
- Forum Commoner
- Posts: 45
- Joined: Fri Jan 24, 2003 12:14 am
Ok... so i have the array/write setup like this
ok, it will do what it is suppose to do (write file), only if the %_POST[q5] has been slectected on the HTML posting page, BUT will only write the one file, in this case...
<input name="q5" type="checkbox" value="Severe_Weather_Warning.txt"> Severe Weather Warning<br>
so $_POST[q5] = Severe_Weather_Warning.txt...
the result is (even with q4, q3, q2 selected...)
Success, wrote (AS_sss.txt) to file (Severe_Weather_Warning.txt)
(AS_sss.txt is $rContents/$filename
)
IT should write the other files corrosponding with q2 q3 q4 etc etc but it doesn't..
WHEN q5 hasn't been selected on the html post page, the i get this error:
Warning: fopen(Users/): failed to open stream: Is a directory in /home/canberra/public_html/wwxs/adduser.php on line 48
Cannot open file ()
...
When i add in the while loop, and have q5 unslected, the same thing occurs, when i have q5 selected the while loop runs indefinatley, rewriting the same (q5) file over and over....
Strange but true...
Code: Select all
<?php
$warnings = array($_POST[q],$_POST[q2],$_POST[q3],$_POST[q4],$_POST[q5]);
foreach ($warnings as $w){
$warning = $w;}
//then the file write code
$rContents = "$filename";
$dir = "Users";
if (!$handle = fopen("$dir/$warning", 'awb+')) {
echo "<br>Cannot open file ($warning)";
exit;
}
// Write content to file.
if (fwrite($handle,"\r\n $rContents") === FALSE) {
echo "<br>Cannot write to file ($warning)";
exit;
}
echo "<br>Success, wrote ($rContents) to file ($warning)";
fclose($handle);
?><input name="q5" type="checkbox" value="Severe_Weather_Warning.txt"> Severe Weather Warning<br>
so $_POST[q5] = Severe_Weather_Warning.txt...
the result is (even with q4, q3, q2 selected...)
Success, wrote (AS_sss.txt) to file (Severe_Weather_Warning.txt)
(AS_sss.txt is $rContents/$filename
IT should write the other files corrosponding with q2 q3 q4 etc etc but it doesn't..
WHEN q5 hasn't been selected on the html post page, the i get this error:
Warning: fopen(Users/): failed to open stream: Is a directory in /home/canberra/public_html/wwxs/adduser.php on line 48
Cannot open file ()
...
When i add in the while loop, and have q5 unslected, the same thing occurs, when i have q5 selected the while loop runs indefinatley, rewriting the same (q5) file over and over....
Strange but true...
-
Simon Angell
- Forum Commoner
- Posts: 45
- Joined: Fri Jan 24, 2003 12:14 am
-
Simon Angell
- Forum Commoner
- Posts: 45
- Joined: Fri Jan 24, 2003 12:14 am