I am not sure how to work with PHP. I am learning...First time using PHP. I am working on a survey form do today. I am using a script that I copied from some site. What it does it writes the inf of a form into a txt file. It works fine . But. some of the questions on the survey have more that one answer (you can check one or more check boxes). For the question w/checkboxes.The script will write int the txt the last selection checked. I need to be able to write all selected options to the txt file and the one that are not check show as empty on the txt file. I will use the content of the txt file to create graphics. I don't like just to copy script but I need to finish this 30 question survey by today.
This is a sample of what i have:
<html>
<head>
<title> </title>
</head>
<body>
<form action="DataCollector.php" method="post" name="survey">
<input type="hidden" name="n" value=0>
<table width="92%" cellpadding="1" cellspacing="1" bordercolor="#CCCCCC" class="bodyBlueText">
<tr>
<td colspan="6"><strong>4.</strong> Organization <br>
<select name="q4" id="select">
<option selected>Select One
<option value="Option1">Option1
<option value="Option2">Option2
<option value="Option3">Option3
<option value="Option4">Option4
<option value="Option5">Option5
</select></td>
</tr>
<tr bgcolor="#FFFFFF">
<td> </td>
<td> </td>
</tr>
<tr>
<td <p><strong>5</strong>. What is your professional focus <br>
<input type="checkbox" name="q5" value="Health and Wellness">
Health and Wellness<br>
<input type="checkbox" name="q5" value="Diversity">
Diversity/EEO<br>
<input type="checkbox" name="q5" value="Work">
Work/Life<br>
<input type="checkbox" name="q5" value="Employee Assistance Programs">
Employee Assistance Programs<br>
<input type="checkbox" name="q5" value="Employee Relations">
Employee Relations<br>
<input type="checkbox" name="q5" value="Benefits">
Benefits<br>
<input type="checkbox" name="q5" value="Other">
Other<br>
</td>
</tr>
<tr>
<td><strong>6.</strong> Question 6</td>
</tr>
<tr>
<td><select name="q6" id="q6">
<option selected>Select One
<option value="Twice a year (all day sessions)">Twice a year (all day
sessions)
<option value="Twice a year (half day sessions)">Twice a year (half day
sessions)
<option value="Quarterly (half day sessions)">Quarterly (half day sessions)
<option value="Other">Other
</select></td>
</tr>
<tr>
<td><strong>7.</strong> WQuestion 7</td>
</tr>
<tr>
<td><p>
<input name="q7" type="radio" value="Yes">
Yes
<input type="radio" name="q7" value="No">
No<br>
</p>
</td>
</tr>
<tr>
<td><strong>8.</strong> Question 8?</td>
</tr>
<tr>
<td><input type="radio" name="q8" value="Yes">
Yes
<input type="radio" name="q8" value="No">
No<br>
</td>
<td> </td>
</tr>
<tr>
<td><br><strong>14.</strong> Question 14<br>
<input type="checkbox" name="q14" value="Conference information"> Conference information<br>
<input type="checkbox" name="q14" value="Quick Tips for Workplace Effectiveness"> Quick Tips for Workplace Effectiveness<br>
<input type="checkbox" name="q14" value="Calendar"> Calendar<br>
<input type="checkbox" name="q14" value="Resources Page with links to other helpful websites"> Resources Page with links to other helpful websites<br>
<input type="checkbox" name="q14" value="Job opportunities"> Job opportunities</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><strong>15.</strong> Quetion 15<br>
<textarea name="q15" cols="45"></textarea></td>
</tr>
<tr>
<td><input type="submit" name="Submit" value="Submit Survey"></td>
</tr>
</table>
</form>
</body>
</html>
---------------------php file
<?php
############################
# modify path to text file
############################
$data[0] = "file.txt";
###################################
# OPEN FILE AND WRITES TO A TXT FILE
###################################
if(!$fp = fopen($data[$_REQUEST['n']], "a")) die ("Cannot open data file");
array_shift($_REQUEST);
$size = sizeof($_REQUEST);
for($i=0; $i<$size; $i++) {
$str = $str . array_shift($_REQUEST);
if(!($i==($size-1))) {
$str = $str . ", ";
}
}
fwrite($fp, $str . "\n\r");
echo "<p>Thank You</p><p>The data was successfully saved.</p>";
?>