- Impact
- 24
Hello,
Trying to process a form with 2 sets of checkboxes and sending results in email but getting stumped.
In the processing page, I'm scrubbing data with function check_input then inserting it into the email body.
As is, the script is returning bad arguments and cannot modify header info. The culprits:
$flooringType = implode(', ', $_POST['flooringType']);
$roomsFlooring = implode(', ', $_POST['$roomsFlooring']);
If I use only 1 implode statement, the script works and properly parses data, but with both implode statements in there it errors out.
process.php:
Your input is greatly appreciated!
Trying to process a form with 2 sets of checkboxes and sending results in email but getting stumped.
In the processing page, I'm scrubbing data with function check_input then inserting it into the email body.
As is, the script is returning bad arguments and cannot modify header info. The culprits:
$flooringType = implode(', ', $_POST['flooringType']);
$roomsFlooring = implode(', ', $_POST['$roomsFlooring']);
If I use only 1 implode statement, the script works and properly parses data, but with both implode statements in there it errors out.
process.php:
Code:
<?php
/* Scrub form input using check_input function */
$firstName = check_input($_POST['firstName']);
$lastName = check_input($_POST['lastName']);
$address = check_input($_POST['address']);
$city = check_input($_POST['city']);
$zip = check_input($_POST['zip']);
$crossStreets = check_input($_POST['crossStreets']);
$phone = check_input($_POST['phone']);
$areaCode = check_input($_POST['areaCode']);
$phone1 = check_input($_POST['phone1']);
$phone2 = check_input($_POST['phone2']);
$cell = check_input($_POST['cell']);
$email = check_input($_POST['email']);
$otherDetails = check_input($_POST['otherDetails']);
$apptDate = check_input($_POST['apptDate']);
$apptTime = check_input($_POST['apptTime']);
$comments = check_input($_POST['comments']);
/* Handle checkbox arrays */
$flooringType = implode(', ', $_POST['flooringType']);
$roomsFlooring = implode(', ', $_POST['$roomsFlooring']);
/* Send the message using mail() function */
mail("...edited on purpose to save forum space" );
/* Redirect visitor to the thank you page */
header('Location: thankyou.php');
exit();
/* Functions to scrub data and error message for required form fields */
function check_input($data, $problem='')
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
if ($problem && strlen($data) == 0)
{
show_error($problem);
}
return $data;
}
function show_error($myError)
{
?>
<script language="javascript" type="text/javascript">
alert('Please fill in the following information:\n\n<?php echo $myError; ?>');
onclick = history.back();
</script>
<noscript>Please fill in the following information:
<?php echo $myError; ?></noscript>
<?php
exit();
}
?>
Your input is greatly appreciated!
Last edited:







