Сообщение не захватывает ответ флажка - PullRequest
0 голосов
/ 15 января 2019

У меня есть форма с группой флажков, которые, когда я публикую в базу данных, ответы не фиксируются. Отчет об ошибках ничего не показывает, и поле пустое.

Странная вещь, которую я нахожу, состоит в том, что у меня есть настройка второй группы флажков, точно такая же, как и при публикации.

Поле базы данных:

name: LAB_Results
type: text

Моя группа форм:

<div class="form-row">
    <div class="col-lg-4 mb-2">
      <label >&nbsp;3. LABORATORY RESULTS: within the past 6 months (please submit the results)</label>
    </div>
    <div class="col-lg-8 mb-2">
        <ul class="list-group list-group-flush">
            <li class="list-group-item">
                <div class="form-check form-check-inline">
                    <input class="form-check-input" type="checkbox"  id="LAB_Results[]" name="LAB_Results[]"  value="Chemistry Profile">
                    <label class="form-check-label" >Chemistry Profile</label>
                </div>

                <div class="form-check form-check-inline">
                    <input class="form-check-input" type="checkbox" name="LAB_Results[]" id="Lab_Results[]"  value="CBC">
                    <label class="form-check-label" >Complete Blood Count</label>
                </div>

                <div class="form-check form-check-inline">
                    <input class="form-check-input" type="checkbox" name="LAB_Results[]" id="Lab_Results[]" value="Urinalysis">
                    <label class="form-check-label" >Urinalysis</label>
                </div>

                <div class="form-check form-check-inline">
                    <input class="form-check-input" type="checkbox" name="LAB_Results[]" id="Lab_Results[]" value="Urine Culture & Susceptibility">
                    <label class="form-check-label" >Urine Culture & Susceptibility</label>
                </div>

                <div class="form-check form-check-inline">
                    <input class="form-check-input" type="checkbox" name="LAB_Results[]" id="Lab_Results[]" value="Skin Bacterial Culture & Susceptibility">
                    <label class="form-check-label" >Skin Bacterial Culture & Susceptibility</label>
                </div>
                &nbsp;&nbsp;
                <div class="form-check form-check-inline">
                    <label class="form-check-label" >Other Test(s)</label>&nbsp;
                    <input class="form-check-input" type="text" id="Lab_Results[]" name="LAB_Results[]" placeholder="Other Test(s)">

                </div>

            </li>
        </ul>

    </div>
</div>      

</div><!-- end of card div -->  

Мой пост скрипт:

<?PHP

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

/*** THIS! ***/
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);

$mysqli = new mysqli("information removed");
if (mysqli_connect_error()) { echo mysqli_connect_error(); exit; }

if (isset($_POST['submit'])){

// The (?,?,?) below are parameter markers used for variable binding
$sql = "INSERT INTO tbl_dermatology_form_rdvm (date_submitted, UMNCaseNo, ClientName, ClientPhone, Pet_Name, Species, Breed, rDVM_Clinic, rDVM, Reason_for_Referral, Relevant_History, Relevant_Clinical_Signs, Pruritus_Present, Photos_Available, Photos_Submitted, Skin_Scrapings, Skin_Scrapings_Results, Ear_Cytology, Ear_Cytology_Results, Skin_Cytology, Skin_Cytology_Results, Fungal_Culture, Fungal_Culture_Results, FNA, FNA_Results, Biopsy, Biopsy_Results, Other_Test, Other_Test_Results, Allergy_Test, Allergy_Test_Date, Food_Trial, Food_Trial_Diet, Food_Trial_Duration, Food_Trial_Response, LAB_Results, P_Tx_1, P_Tx_1_Response, P_Tx_2, P_Tx_2_Response, P_Tx_3, P_Tx_3_Response, P_Tx_4, P_Tx_4_Response, P_Tx_5, P_Tx_5_Response, C_Tx_1, C_Tx_1_Response, C_Tx_2, C_Tx_2_Response, C_Tx_3, C_Tx_3_Response, C_Tx_4, C_Tx_4_Response, C_Tx_5, C_Tx_5_Response, Additional_Care, Unrelated_Services, Comments_Special_Requests, rDVM_email, Vet_Visit_Behavior, Client_Patient_Concerns
) VALUES (NOW(),?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
$stmt = $mysqli->prepare($sql);
$stmt->bind_param("sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss", $UMNCaseNo, $ClientName, $ClientPhone, $Pet_Name, $Species, $Breed, $rDVM_Clinic, $rDVM, $Reason_for_Referral, $Relevant_History, $Relevant_Clinical_Signs, $Pruritus_Present, $Photos_Available, $Photos_Submitted, $Skin_Scrapings, $Skin_Scrapings_Results, $Ear_Cytology, $Ear_Cytology_Results, $Skin_Cytology, $Skin_Cytology_Results, $Fungal_Culture, $Fungal_Culture_Results, $FNA, $FNA_Results, $Biopsy, $Biopsy_Results, $Other_Test, $Other_Test_Results, $Allergy_Test, $Allergy_Test_Date, $Food_Trial, $Food_Trial_Diet, $Food_Trial_Duration, $Food_Trial_Response, $LAB_Results, $P_Tx_1, $P_Tx_1_Response, $P_Tx_2, $P_Tx_2_Response, $P_Tx_3, $P_Tx_3_Response, $P_Tx_4, $P_Tx_4_Response, $P_Tx_5, $P_Tx_5_Response, $C_Tx_1, $C_Tx_1_Response, $C_Tx_2, $C_Tx_2_Response, $C_Tx_3, $C_Tx_3_Response, $C_Tx_4, $C_Tx_4_Response, $C_Tx_5, $C_Tx_5_Response, $Additional_Care, $Unrelated_Services, $Comments_Special_Requests, $rDVM_email, $Vet_Visit_Behavior, $Client_Patient_Concerns ); // bind variables

// Patient UMN Case Number
if (trim($_POST['UMNCaseNo']) == '') {
  $UMNCaseNo = NULL;
} else {
  $UMNCaseNo = trim($_POST['UMNCaseNo']);
}

// Client Name
if (trim($_POST['ClientName']) == '') {
  $ClientName = NULL;
} else {
  $ClientName = trim($_POST['ClientName']);
}


//Patient Name
if (trim($_POST['Pet_Name']) == '') {
  $Pet_Name = NULL;
} else {
  $Pet_Name = trim($_POST['Pet_Name']);
}

//Patient Species
if (trim($_POST['Species']) == '') {
  $Species = NULL;
} else {
  $Species = trim($_POST['Species']);
}

//Patient Breed
if (trim($_POST['Breed']) == '') {
  $Breed = NULL;
} else {
  $Breed = trim($_POST['Breed']);
}

//rDVM_Clinic
if (trim($_POST['rDVM_Clinic']) == '') {
  $rDVM_Clinic = NULL;
} else {
  $rDVM_Clinic = trim($_POST['rDVM_Clinic']);
}

//rDVM
if (trim($_POST['rDVM']) == '') {
  $rDVM = NULL;
} else {
  $rDVM = trim($_POST['rDVM']);
}   

//Reason_for_Referral
if (trim($_POST['Reason_for_Referral']) == '') {
  $Reason_for_Referral = NULL;
} else {
  $Reason_for_Referral = trim($_POST['Reason_for_Referral']);
}

//Relevant_History
if(isset($_POST['Relevant_History']))
   {
    $Relevant_History = $_POST["Relevant_History"];
   }    
else {
    $Relevant_History = NULL;
     }

// Relevant_Clinical_Signs
if(isset($_POST['Relevant_Clinical_Signs']))
   {
    $Relevant_Clinical_Signs = $_POST["Relevant_Clinical_Signs"];
   }    
else {
    $Relevant_Clinical_Signs = NULL;
     }

// Pruritus_Present
if(isset($_POST['Pruritus_Present']))
   {
    $Pruritus_Present = $_POST["Pruritus_Present"];
   }    
else {
    $Pruritus_Present = NULL;
     }

// Photos_Available
if(isset($_POST['Photos_Available']))
   {
    $Photos_Available = $_POST["Photos_Available"];
   }    
else {
    $Photos_Available = NULL;
     }

// Photos_Submitted
if(isset($_POST['Photos_Submitted']))
   {
    $Photos_Submitted = $_POST["Photos_Submitted"];
   }    
else {
    $Photos_Submitted = NULL;
     }

// Skin_Scrapings
if(isset($_POST['Skin_Scrapings']))
   {
    $Skin_Scrapings = 'Y';
   }    
else {
    $Skin_Scrapings = NULL;
     }


// Skin_Scrapings_Results
if(isset($_POST['Skin_Scrapings_Results']))
   {
    $Skin_Scrapings_Results = $_POST["Skin_Scrapings_Results"];
   }    
else {
    $Skin_Scrapings_Results = NULL;
     }

// Ear_Cytology
if(isset($_POST['Ear_Cytology']))
   {
    $Ear_Cytology = 'Y';
   }    
else {
    $Ear_Cytology = NULL;
     }

// Ear_Cytology_Results
if(isset($_POST['Ear_Cytology_Results']))
   {
    $Ear_Cytology_Results = $_POST["Ear_Cytology_Results"];
   }    
else {
    $Ear_Cytology_Results = NULL;
     }

// Skin_Cytology
if(isset($_POST['Skin_Cytology']))
   {
    $Skin_Cytology = 'Y';
   }    
else {
    $Skin_Cytology = NULL;
     }

// Skin_Cytology_Results
if(isset($_POST['Skin_Cytology_Results']))
   {
    $Skin_Cytology_Results = $_POST["Skin_Cytology_Results"];
   }    
else {
    $Skin_Cytology_Results = NULL;
     }

// Fungal_Culture
if(isset($_POST['Fungal_Culture']))
   {
    $Fungal_Culture = 'Y';
   }    
else {
    $Fungal_Culture = NULL;
     }

// Fungal_Culture_Results
if(isset($_POST['Fungal_Culture_Results']))
   {
    $Fungal_Culture_Results = $_POST["Fungal_Culture_Results"];
   }    
else {
    $Fungal_Culture_Results = NULL;
     }

// FNA
if(isset($_POST['FNA']))
   {
    $FNA = 'Y';
   }    
else {
    $FNA = NULL;
     }  

// FNA_Results
if(isset($_POST['FNA_Results']))
   {
    $FNA_Results = $_POST["FNA_Results"];
   }    
else {
    $FNA_Results = NULL;
     }

// Biopsy
if(isset($_POST['Biopsy']))
   {
    $Biopsy = 'Y';
   }    
else {
    $Biopsy = NULL;
     }

// Biopsy_Results
if(isset($_POST['Biopsy_Results']))
   {
    $Biopsy_Results = $_POST["Biopsy_Results"];
   }    
else {
    $Biopsy_Results = NULL;
     }


if(isset($_POST['Other_Test']))
   {
    $Other_Test = 'Y';
   }    
else {
    $Other_Test = NULL;
     }

// Other_Test_Results
if(isset($_POST['Other_Test_Results']))
   {
    $Other_Test_Results = $_POST["Other_Test_Results"];
   }    
else {
    $Other_Test_Results = NULL;
     }

// Allergy_Test
if(isset($_POST['Allergy_Test']))
   {
    $Allergy_Test = $_POST["Allergy_Test"];
   }    
else {
    $Allergy_Test = NULL;
     }

// Allergy_Test_Date
if(isset($_POST['Allergy_Test_Date']))
   {
    $Allergy_Test_Date = $_POST["Allergy_Test_Date"];
   }    
else {
    $Allergy_Test_Date = NULL;
     }


// Food_Trial
if(isset($_POST['Food_Trial']))
   {
    $Food_Trial = $_POST["Food_Trial"];
   }    
else {
    $Food_Trial = NULL;
     }

// Food_Trial_Diet
if(isset($_POST['Food_Trial_Diet']))
   {
    $Food_Trial_Diet = $_POST["Food_Trial_Diet"];
   }    
else {
    $Food_Trial_Diet = NULL;
     }  

// Food_Trial_Duration
if(isset($_POST['Food_Trial_Duration']))
   {
    $Food_Trial_Duration = $_POST["Food_Trial_Duration"];
   }    
else {
    $Food_Trial_Duration = NULL;
     }

// Food_Trial_Response
if(isset($_POST['Food_Trial_Response']))
   {
    $Food_Trial_Response = $_POST["Food_Trial_Response"];
   }    
else {
    $Food_Trial_Response = NULL;
     }

// lab results
    if(!empty($_POST['LAB_Results'])){
        $Lab_Results = implode(', ', $_POST['LAB_Results']);
    } else {
        $Lab_Results = NULL;
    }

    // vet visit behavior
    if(!empty($_POST['Vet_Visit_Behavior'])){
        $Vet_Visit_Behavior = implode(', ', $_POST['Vet_Visit_Behavior']);
    } else {
        $Vet_Visit_Behavior = NULL;
    }


// P_Tx_1
if(isset($_POST['P_Tx_1']))
   {
    $P_Tx_1 = $_POST["P_Tx_1"];
   }    
else {
    $P_Tx_1 = NULL;
     }

// P_Tx_1_Response
if(isset($_POST['P_Tx_1_Response']))
   {
    $P_Tx_1_Response = $_POST["P_Tx_1_Response"];
   }    
else {
    $P_Tx_1_Response = NULL;
     }

// P_Tx_2
if(isset($_POST['P_Tx_2']))
   {
    $P_Tx_2 = $_POST["P_Tx_2"];
   }    
else {
    $P_Tx_2 = NULL;
     }

// P_Tx_2_Response
if(isset($_POST['P_Tx_2_Response']))
   {
    $P_Tx_2_Response = $_POST["P_Tx_2_Response"];
   }    
else {
    $P_Tx_2_Response = NULL;
     }  

// P_Tx_3
if(isset($_POST['P_Tx_3']))
   {
    $P_Tx_3 = $_POST["P_Tx_3"];
   }    
else {
    $P_Tx_3 = NULL;
     }

// P_Tx_3_Response
if(isset($_POST['P_Tx_3_Response']))
   {
    $P_Tx_3_Response = $_POST["P_Tx_3_Response"];
   }    
else {
    $P_Tx_3_Response = NULL;
     }      

// P_Tx_4
if(isset($_POST['P_Tx_4']))
   {
    $P_Tx_4 = $_POST["P_Tx_4"];
   }    
else {
    $P_Tx_4 = NULL;
     }

// P_Tx_4_Response
if(isset($_POST['P_Tx_4_Response']))
   {
    $P_Tx_4_Response = $_POST["P_Tx_4_Response"];
   }    
else {
    $P_Tx_4_Response = NULL;
     }      

// P_Tx_5
if(isset($_POST['P_Tx_5']))
   {
    $P_Tx_5 = $_POST["P_Tx_5"];
   }    
else {
    $P_Tx_5 = NULL;
     }

// P_Tx_5_Response
if(isset($_POST['P_Tx_5_Response']))
   {
    $P_Tx_5_Response = $_POST["P_Tx_5_Response"];
   }    
else {
    $P_Tx_5_Response = NULL;
     }  

// C_Tx_1
if(isset($_POST['C_Tx_1']))
   {
    $C_Tx_1 = $_POST["C_Tx_1"];
   }    
else {
    $C_Tx_1 = NULL;
     }

// C_Tx_1_Response
if(isset($_POST['C_Tx_1_Response']))
   {
    $C_Tx_1_Response = $_POST["C_Tx_1_Response"];
   }    
else {
    $C_Tx_1_Response = NULL;
     }

// C_Tx_2
if(isset($_POST['C_Tx_2']))
   {
    $C_Tx_2 = $_POST["C_Tx_2"];
   }    
else {
    $C_Tx_2 = NULL;
     }

// C_Tx_2_Response
if(isset($_POST['C_Tx_2_Response']))
   {
    $C_Tx_2_Response = $_POST["C_Tx_2_Response"];
   }    
else {
    $C_Tx_2_Response = NULL;
     }  

// C_Tx_3
if(isset($_POST['C_Tx_3']))
   {
    $C_Tx_3 = $_POST["C_Tx_3"];
   }    
else {
    $C_Tx_3 = NULL;
     }

// C_Tx_3_Response
if(isset($_POST['C_Tx_3_Response']))
   {
    $C_Tx_3_Response = $_POST["C_Tx_3_Response"];
   }    
else {
    $C_Tx_3_Response = NULL;
     }      

// C_Tx_4
if(isset($_POST['C_Tx_4']))
   {
    $C_Tx_4 = $_POST["C_Tx_4"];
   }    
else {
    $C_Tx_4 = NULL;
     }

// C_Tx_4_Response
if(isset($_POST['C_Tx_4_Response']))
   {
    $C_Tx_4_Response = $_POST["C_Tx_4_Response"];
   }    
else {
    $C_Tx_4_Response = NULL;
     }      

// C_Tx_5
if(isset($_POST['C_Tx_5']))
   {
    $C_Tx_5 = $_POST["C_Tx_5"];
   }    
else {
    $C_Tx_5 = NULL;
     }

// C_Tx_5_Response
if(isset($_POST['C_Tx_5_Response']))
   {
    $C_Tx_5_Response = $_POST["C_Tx_5_Response"];
   }    
else {
    $C_Tx_5_Response = NULL;
     }  

// Additional_Care
if(isset($_POST['Additional_Care']))
   {
    $Additional_Care = $_POST["Additional_Care"];
   }    
else {
    $Additional_Care = NULL;
     }

// Unrelated_Services
if(isset($_POST['Unrelated_Services']))
   {
    $Unrelated_Services = $_POST["Unrelated_Services"];
   }    
else {
    $Unrelated_Services = NULL;
     }  

// Comments_Special_Requests
if(isset($_POST['Comments_Special_Requests']))
   {
    $Comments_Special_Requests = trim($_POST["Comments_Special_Requests"]);
   }    
else {
    $Comments_Special_Requests = NULL;
     }  

// rDVM email address
if(isset($_POST['rDVM_email'])) {
    $rDVM_email = filter_var($_POST['rDVM_email'], FILTER_SANITIZE_EMAIL);
} else {
    $rDVM_email = NULL;
}

// client or patient concerns
if(isset($_POST['Client_Patient_Concerns']))    {
    $Client_Patient_Concerns = trim($_POST['Client_Patient_Concerns']);
} else {
    $Client_Patient_Concerns = NULL;
}   

if ($stmt->execute()) {

$last_id = $stmt->insert_id;
    $headers = "From: " . strip_tags($email) . "\r\n";  
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

    $message = '<html><body><h3>An rDVM Dermatology Questionnaire Has Been Submitted.</h3><br />';
    $message .= "<br />";
    $message .= "<br />";
    $message .= "Thank you&nbsp; " .$rDVM ." &nbsp; for filling out the Dermatology form for " .$Pet_Name . "&nbsp;with,&nbsp;". $ClientName . ". Your information has been received. If indicated, please use the following link <a href=".$url." target='_blank'>" .$url . "</a> to submit any photographs of your patients lesions or documents / test results. ";
    $message .= "<br />";
    $message .= "<br />";
    $message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
    $message .= "<tr style='background: #eee;'>  <td width='178'></td> <td width='380'></td></tr>";
    $message .= "<tr> <td><strong>Case/PA Number:</strong></td>  <td>" . $UMNCaseNo . "</td></tr>";
    $message .= "<tr><td colspan='2'>&nbsp;</td></tr>";
    $message .= "<tr> <td><strong>Client Name:</strong> </td><td>" . $ClientName . "</td></tr>";    
    $message .= "<tr><td colspan='2'>&nbsp;</td></tr>";
    $message .= "<tr><td><strong>Pet Name:</strong></td> <td>" . $Pet_Name . "</td></tr>";  
    $message .= "<tr><td><strong>Species:</strong></td> <td>" . $Species . "</td></tr>";    
    $message .= "<tr><td><strong>Breed:</strong></td> <td>" . $Breed . "</td></tr>";
    $message .= "<tr><td colspan='2'>&nbsp;</td></tr>";
    $message .= "<tr><td><strong>Clinic Name:</strong></td> <td>" . $rDVM_Clinic . "</td></tr>";    
    $message .= "<tr><td><strong>rDVM Name:</strong></td> <td>" . $rDVM . "</td></tr>";
    $message .= "<tr><td colspan='2'>&nbsp;</td></tr>";
    $message .= "<tr style='background: #eee'><td colspan='2'><strong>Reason for Referral & Expectations:</strong></td></tr>";
    $message .= "<tr><td colspan='2'>" . $Reason_for_Referral . "</td></tr>";
    $message .= "<tr><td colspan='2'>&nbsp;</td></tr>";
    $message .= "<tr><td colspan='2'>Link to full history (available to UMN Staff Only): <a href='http://xxx/dermatology/form_view_rdvm.php?id=". $last_id ."' target='_blank'> http://xxx/dermatology/form_view_rdvm.php?id=". $last_id . "</a></td></tr>";
    $message .= "<tr><td colspan='2'>&nbsp;</td></tr>";
    $message .= "</table>";
    $message .= "</body></html>";
    $message .= "<br />";

if(mail($to,$subject,$message,$headers)){
//redirect to the 'thank you' page
echo "<body><br /><br />
Thank you&nbsp; " .$rDVM ." &nbsp; for filling out the Dermatology form for " .$Pet_Name . "&nbsp;with,&nbsp;". $ClientName . ". Your information has been received. Use the following link <a href=".$url." target='_blank'>" .$url . "</a> to submit photographs of your patients lesions or documents / test results
</body>";
} else {
    echo 'Error!';
}

}
}
$stmt->close(); // close the prepared statement
$mysqli->close(); // close the database connection
?>

1 Ответ

0 голосов
/ 15 января 2019

Я бы убрал квадратные скобки в имени поля. Возможно, вы получаете данные в переменной $ _POST ['LAB_Results []'].

Как сказал @noid, вы должны избегать дублирующихся идентификаторов.

Скопировано из комментариев.

Пожалуйста, удалите последнее поле, текстовый ввод с именем Lab_Results, Другое тестирует одно. Возможно, вам придется иметь дело с этим полем отдельно от флажков.

...