Break Issue... Logic Error
So there's obviously a logic error somewhere, as the Do While Loop isn't breaking... Help me please: <?php /* Program: KENNEM_Task 5_Log In. AIM: To create a functional logging in system. Author: Maggie Kennedy Date: 30/08/2017 - 00/00/2017 **********************************************************************/ /*Create arrays with 5 IDs and 5 Password respectively.*/ $ID = array ('George', 'Peter', 'Wendy', 'Sheri', 'DummyID'); //IDs $Pass = array ('GeoNumber1', 'ImissTinkerBell', 'MyKiss', 'Tryme', 'DummyPW'); //Passwords /*Logging In Input.*/ $Check_ID = "Sher"; $Check_Pass = "Tryme"; /*Create a variable to trigger when loggin was successful. Also, create the Position variable*/ $Success = false; $Pos = 0; /*Start a Do While Loop to check whether ID and Pass match.*/ do { if ($Check_ID == $ID[$Pos]) { /*If ID is found in array then check that the password matches*/ if ($Check_Pass == $Pass[$Pos]) { $Success = true; /*Change $Success to true*/ break; } //End of Second If Statement } //End of First If Statement $Pos++; if ($Success == false && $Check_ID == 'DummyID') { break; } //End of Third If Statement } /*End of Do Loop*/ while ($Check_ID != 'DummyID' && $Success == false); /*While there are still IDs left or whenever $Success is still false.*/ if ($Success == true) /*If logging is successful*/ echo "<h2><center>Excellent! you have logged in as: $Check_ID!</center></h2>"; if ($Success == false) echo "<h2><center>Sorry, something went wrong. Make sure you typed in the right ID and Password.</center></h2>"; ?>