Why does this code snippet keep getting Undefined offset: 2, Undefined offset: 7, Undefined offset: 11, respectively? I'm not sure where I'm going wrong,
for($i = 0; $i < $user_length; $i++) // CHECKS IF THE USERNAME, FIRST NAME, IC NUMBER AND CONTACT NUMBER IS ALREADY BEEN REGISTERED AS A MEMBER
{
$userdetail = explode(":", $user[$i]);
if ($_POST['ic'] == $userdetail[2])
{
echo "<h2>Sorry!</h2><p>The ic no is already in use!</p>";
$error = 1;
$i = $user_length;
}
else if ($_POST['phone'] == $userdetail[7])
{
echo "<h2>Sorry!</h2><p>phone no is already in use!</p>";
$error = 1;
$i = $user_length;
}
else if ($_POST['facename'] == $userdetail[10])
{
echo "<h2>Sorry!</h2><p>The Username you provided is already in use!</p>";
$error = 1;
$i = $user_length;
}
}
Here's the text file format the explode is reading from:
u0003:omied:123456-12-1234:male:married:privatesector:dfsfsdf:603-32323242:6016-2343432:omied@gmail.com:omeid123:dingo1234
as you can see, ic, phone, and facename are defined as 2, 7 and 10 following the format of the loop and array.