Added check for internet connection before form submission