There are legitimate online PhD programs, but also many PhD programs from unaccredited schools. Even at legitimate programs, you have to spend the same amount of time on your degree as a student at a traditional school--sometimes more, because there is less structure.
Some online schools send out spam that offers a PhD diploma in far less time than a normal program, usually by offering credit life experience. Other programs are unaccredited and usually not recognized in the academic or professional world.
Research any potential school before entering a PhD program. Claiming a degree from a diploma mill could be grounds for termination because the company may view a diploma mill degree as you lying on your application. Legitimate schools are accredited by one of the six regional accrediting councils, such as the Southern Association of Colleges and Schools and the Middle States Commission on Higher Education. The Department of Education has a complete listing of accredited national and regional agencies (see Resources).