jeudi 1 janvier 2015

Undefined offset from my checkbox form

The following function works fine despite having the "Undefined offset" error but i need to debug it still. Can someone help me spot where the error is?


This is the form :



$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">
}


This is the form handling:



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;




Aucun commentaire:

Enregistrer un commentaire