Jump to content

Trouble with arrays


spoco

Recommended Posts

I have a form that I want the data to e-mail in a message. Everything works except for the checkbox arrays. "Array" displays when I want all values of checked boxes to display.

 

Here is the code, I have bolded where checkbox data should be coming over. I'm not a pro so any help is greatly appreciated.


$message = "<html><body>\r\n";
$message .= "<table width='500' border='0' cellpadding='2'>\r\n";
$message .= "  <tr>\r\n";
$message .= "    <td width='150'>School</td>\r\n";
$message .= "    <td width='350'>" . $_POST['school'] . " </td>\r\n";
$message .= "  </tr>\r\n";
$message .= "  <tr>\r\n";
$message .= "    <td width='150'>Teacher</td>\r\n";
$message .= "    <td width='350'>" . $_POST['teacher'] . "</td>\r\n";
$message .= "  </tr>\r\n";
$message .= "  <tr>\r\n";
$message .= "    <td width='150'>Subject</td>\r\n";
$message .= "    <td width='150'>" . $_POST['subject'] . "</td>\r\n";
$message .= "    <td width='150'>Period</td>\r\n";
$message .= "    <<td width='50'>" . $_POST['period'] . "</td>\r\n";
$message .= "  </tr>\r\n";
$message .= "    <td width='150'>Date</td>\r\n";
$message .= "    <td width='50'>" . $_POST['month'] .  "</td>\r\n";
$message .= "    <td width='15'>" . $_POST['day'] .  "</td>\r\n";
$message .= "    <td width='15'>" . $_POST['year'] .  "</td>\r\n";
$message .= "  </tr>\r\n";
$message .= "    <td width='150'>Time In:</td>\r\n";
$message .= "    <td width='100'>" . $_POST['timeIn'] . "</td>\r\n";
$message .= "    <td width='150'>Time Out:</td>\r\n";
$message .= "    <td width='100'>" . $_POST['timeOut'] . "</td>\r\n";
$message .= "  </tr>\r\n";
$message .= "    <td width='150'>Teacher Location Upon Entrance</td>\r\n";
[b]$message .= "    <td width='350'>" . $_POST['q6_1Teacher6'] . "</td>\r\n";[/b]
$message .= "  </tr>\r\n";
$message .= "    <td width='150'>Comments</td>\r\n";
$message .= "    <td width='350'>" . $_POST['q7_comments7'] . "</td>\r\n";
$message .= "  </tr>\r\n";
$message .= "    <td width='150'>Student Engagement</td>\r\n";
[b]$message .= "    <td width='350'>" . $_POST['q11_2Student'] . "</td>\r\n";[/b]
$message .= "  </tr>\r\n";
$message .= "    <td width='150'>Students Engaged/Total Students</td>\r\n";
$message .= "    <td width='350'>" . $_POST['q12_studentsEngagedtotal'] . "</td>\r\n";
$message .= "  </tr>\r\n";
$message .= "    <td width='150'>Comments</td>\r\n";
$message .= "    <td width='350'>" . $_POST['q15_comments15'] . "</td>\r\n";
$message .= "  </tr>\r\n";
$message .= "    <td width='150'>Teaching Alignment</td>\r\n";
[b]$message .= "    <td width='350'>" . $_POST['q17_3Teaching17'] . "</td>\r\n";[/b]
$message .= "  </tr>\r\n";
$message .= "    <td width='150'>Comments</td>\r\n";
$message .= "    <td width='350'>" . $_POST['q18_comments18'] . "</td>\r\n";
$message .= "  </tr>\r\n";
$message .= "    <td width='150'>Identified Learning</td>\r\n";
[b]$message .= "    <td width='350'>" . $_POST['q13_4Identified'] . "</td>\r\n";[/b]
$message .= "  </tr>\r\n";
$message .= "    <td width='150'>Comments</td>\r\n";
$message .= "    <td width='350'>" . $_POST['q16_comments16'] . "</td>\r\n";
$message .= "  </tr>\r\n";
$message .= "    <td width='150'>Rigor Rate</td>\r\n";
[b]$message .= "    <td width='350'>" . $_POST['q20_5Rigor'] . "</td>\r\n";[/b]
$message .= "  </tr>\r\n";
$message .= "    <td width='150'>Comments</td>\r\n";
$message .= "    <td width='350'>" . $_POST['q21_comments21'] . "</td>\r\n";
$message .= "  </tr>\r\n";
$message .= "    <td width='150'>Assessment Practice</td>\r\n";
[b]$message .= "    <td width='350'>" . $_POST['q22_6Assessment'] . "</td>\r\n";[/b]
$message .= "  </tr>\r\n";
$message .= "    <td width='150'>Comments</td>\r\n";
$message .= "    <td width='350'>" . $_POST['q27_comments27'] . "</td>\r\n";
$message .= "  </tr>\r\n";
$message .= "    <td width='150'>Instructional Practice</td>\r\n";
[b]$message .= "    <td width='350'>" . $_POST['q24_studentDirected'] . "</td>\r\n";[/b]
$message .= "  </tr>\r\n";
$message .= "    <td width='150'>Comments</td>\r\n";
$message .= "    <td width='350'>" . $_POST['q23_comments23'] . "</td>\r\n";
$message .= "  </tr>\r\n";
$message .= "    <td width='150'>Learning Environment</td>\r\n";
[b]$message .= "    <td width='350'>" . $_POST['q28_8Learning'] . "</td>\r\n";[/b]
$message .= "  </tr>\r\n";
$message .= "    <td width='150'>Comments</td>\r\n";
$message .= "    <td width='350'>" . $_POST['q29_comments29'] . "</td>\r\n";
$message .= "  </tr>\r\n";
$message .= "</table>\r\n";
$message .= "</body></html>";

Link to comment
https://forums.phpfreaks.com/topic/216815-trouble-with-arrays/
Share on other sites

php handles checkboxes differently that your type="text".

 

This is how I address the problem you are facing. For each checkbox option I create an

if

block like so:

 

if(isset($_POST["checkBoxName"]["checkBoxalue"])) { 
  echo $_POST['checkBoxName'];
} else {
exit();
};

 

The above code might not work right, but it should give you the right direction! You basically want to store each checkbox Name and Value and then once it's stored you can insert it into MySQL or a variable for email, posting to a page, etc..

Link to comment
https://forums.phpfreaks.com/topic/216815-trouble-with-arrays/#findComment-1126538
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.