if session ok { print welcome message with email and name if action is update { update the users record if update failed { print failed update } else { print user updated } } print form } else session not ok { if email pw are blank { set mode to new } else email and pw not blank { check email if email matches { if pw match { set mode to valid assign cookies } else pw not match { increase numfail get numfail value set mode to invalid pass } } else email does not match { set mode to invalid login } } if mode is not valid { print header with no cookie if mode is invalid pass { show numfail error } elsif mode is invalid login { print invalid login error } elsif mode is new { print welcome } print form } }