我有一個查詢字符串中有一堆表單字段值。其中一個字段是一個複選框,並創建重複的參數,例如:如何處理查詢字符串中的複選框值?
employee_selection_needs =貓& employee_selection_needs =狗& employee_selection_needs =豬
我需要把所有這些複選框的值代入?一個變量提交給HubSpot API。我怎麼能做到這一點?我用foreach
循環嘗試過,但這似乎不起作用。
$firstname = $_POST["firstname"];
$lastname = $_POST["lastname"];
$email = $_POST["email"];
$organization_name = $_POST["organization_name"];
$phone = $_POST["phone"];
$best_describes_org = $_POST["best_describes_org"];
$organizations_safety = $_POST["organizations_safety"];
$confident_interview_process = $_POST["confident_interview_process"];
$needs_around_leadership = $_POST["needs_around_leadership"];
$used_employee_assessments = $_POST["used_employee_assessments"];
$hire_annually = $_POST["hire_annually"];
foreach($_POST['employee_selection_needs'] as $needs) {
$employee_selection_needs .= $needs;
}
//Need to populate these variable with values from the form.
$str_post = "firstname=" . urlencode($firstname)
. "&lastname=" . urlencode($lastname)
. "&email=" . urlencode($email)
. "&phone=" . urlencode($phonenumber)
. "&organization_name=" . urlencode($organization_name)
. "&best_describes_org=" . urlencode($best_describes_org)
. "&employee_selection_needs=" . urlencode($employee_selection_needs)
. "&organizations_safety=" . urlencode($organizations_safety)
. "&confident_interview_process=" . urlencode($confident_interview_process)
. "&needs_around_leadership=" . urlencode($needs_around_leadership)
. "&used_employee_assessments=" . urlencode($used_employee_assessments)
. "&hire_annually=" . urlencode($hire_annually)
. "&hs_context=" . urlencode($hs_context_json); //Leave this one be
是啊..這是HubSpot,雖然,我不能[]添加名稱:( – Dustin