i am writing a cleanup script which will delete all the entries in db tables which will delete all the old entries beyond a input date.

The problem i am facing is- when the date input is invalid then it is deleting all the files..
what i want is when an invalid date is entered then it should just exit the process without any deletion.

can anyone help?