I am developing a desktop app which will store data offline but whenever the desktop gets a connection a php script should detect it (cron job) and upload it to the online server like this:
while(true){
if(connected == true){
// run code;
else{
// wait to get connection
}
}