
    for(i=0; i<1; i++) 
{
    lcd_disp1(lcd_door,0);     //prompt the user to press a button to open or close a door
    temp=input_keypad();       //wait and see if the user gives input
    if(temp != ERROR_VAL)break;// if input is given skip the next 2 display statements
                               // and go to the if statement present after this for loop

    lcd_disp1(lcd_change,0);   //prompt the user to press a button to change password
    temp=input_keypad();       //wait and see if the user gives input
    if(temp != ERROR_VAL)break;// if input is given skip the next display statements
                               // and go to the if statement present after this for loop

    lcd_disp1(lcd_exit,0);
    temp=input_keypad();
    //if(temp != ERROR_VAL)break; as you pointed out this is my mistake
}

if(temp==KEY_DOOR_OPENCLOSE)
{
   if(door_state==1)
 {........
