我正在使用“reusableforms.com”PHP 表單腳本。該表格運行良好。但是我在多輸入復選框值上遇到錯誤。
如何獲取多輸入復選框值?
HTML代碼:
<div class="form-box">
<label>Choose which of the following are most important to you:</label>
<div class="multi-select">
<div class="custom-select">
<input type="checkbox" id="hight-rating" value="High Rating" name="important" hidden>
<label for="hight-rating">High Rating</label>
</div>
<div class="custom-select">
<input type="checkbox" id="mobile-phone-app" value="Mobile phone app" name="important" hidden>
<label for="mobile-phone-app">Mobile phone app</label>
</div>
<div class="custom-select">
<input type="checkbox" id="vendor-management" value="Vendor management" name="important" hidden>
<label for="vendor-management">Vendor management</label>
</div>
</div>
</div>
處理程式
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require_once './vendor/autoload.php';
use FormGuide\Handlx\FormHandler;
$pp = new FormHandler();
$validator = $pp->getValidator();
$validator->fields(['name','email', 'phone', 'address', 'property', 'following', 'units', 'date'])->areRequired()->maxLength(50);
$validator->field('important[]')->maxLength(5000);
$validator->field('email')->isEmail();
$pp->sendEmailTo('[email protected]'); // ← Your email here
echo $pp->process($_POST);
?>
謝謝你。
uj5u.com熱心網友回復:
根據您的問題,您沒有將復選框宣告為您需要的陣列:
<input type="checkbox" id="hight-rating" value="High Rating" name="important[]" hidden>
但是,如果這沒有幫助,那么再詳細說明這個問題會很有用。
uj5u.com熱心網友回復:
在 html 中使用
<input type="checkbox" id="mobile-phone-app" value="Mobile phone app" name="important[]" hidden>
在 php 中,您將收到陣列中的資料,因此您大喊使用計數而不是 maxLength
$important = $_GET['important'];
$count = count($important);
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/346207.html
上一篇:在svg中創建內部陰影
