与我的复选框表单的未定义偏移量

Undefined offset from my checkbox form

尽管出现 "Undefined offset" 错误,但以下函数仍能正常工作,但我仍需要对其进行调试。谁能帮我找出错误所在?

这是表格:

$query = "SELECT * FROM application WHERE Shortlist_status = 1 AND Interview_datetime !=  '' AND Email_checked ='' ORDER BY Candidate_id ASC";
$result = mysqli_query($link, $query) or die(mysqli_error($link));

while ($row = mysqli_fetch_array($result)) {

<input type="hidden" name="can_id[]" value=<?php echo $canid ?>>
<input type="hidden" name="job_id[]" value=<?php echo $jobid ?>>

(Some codes)

<input name="email[]" id="id" type="checkbox" value="1">
}

这是表单处理:

foreach ($_POST['can_id'] as $i => $candidate_id) {
$job_id = $_POST['job_id'][$i];

$email = $_POST['email'][$i];

$insertQuery = "UPDATE application SET Email_checked = '$email' WHERE Candidate_id = $candidate_id AND Job_id = $job_id";
$inserted = mysqli_query($link, $insertQuery) or die(mysqli_error($link));
}

if($inserted)
{
    $message = 'Application successfully update <br><a href="interview.php">Manage Candidate</a>';; 
}
else
{
  $message = 'Application failed <br><a href="interview.php">Manage Candidate</a>';
}
echo $message;

根据您在评论中对错误的描述,我想问题可以这样解决:

$email = isset($_POST['email'][$i]) ? $_POST['email'][$i] : "otherValue";

如果没有设置 "otherValue" 则用你需要的替换(可能 "0"

$email = isset($request->email[$i]) ? $request->email[$i] : 0;