Both phasers and flangers are "synth" effects. The incoming signal is analyzed, and additional waveforms, based on the source, are combined with or substituted for the "clean" signal to produce the effect. This makes them distinct from "gain"-based effects that work primarily by altering the amplitude of various components of the original signal directly, such as overdrive/distortion, equalization, notching (wah-wahs) etc.
The difference is that a phaser works on a phase delay, while a flanger works on a time delay. Similar in theory, but one is frequency-based, the other is solely time-based.
A phaser takes in the signal and splits it into at least two paths. One path is left unaltered, to be recombined before exiting the effect circuit. The other is put through an "all-pass filter". Its basic idea is not dissimilar from the tone pot on passive instruments in that it uses a capacitor, except here, instead of using the reactance qualities of a capacitor to create a "high-pass" or "low-pass" tone-altering filter, another property is used; the fact that AC current passing through a capacitor is phase-shifted by 90 degrees. The sound output from the all-pass filter is roughly the same signal strength as the input, thanks to a negative-feedback op-amp that corrects for the frequency-dependent attentuation through the capacitor, but each frequency component of the waveform is delayed by a different amount of phase with the original signal (with the "corner" frequency, typically controlled by the ratio of the capacitor's rating and the setting of a potentiometer, being altered by 90*). When recombined, the various frequencies combine constructively and destructively. Phasers often also include a modulating feedback loop, which varies the inputs to the all-pass filter and thus changes the corner frequency of the phase shift over time, producing a cyclical sweeping effect.
Phasers are the extreme of "chorus"-type synth effects, which use a similar circuit design, but the amount of variation produced is smaller (but often deeper; the circuit is split and phase-shifted more) to sound more natural.
A flanger works similarly, but instead of an all-pass, phase-shifting circuit, the altered branch of the signal is fed into a delay circuit that feeds it back out, more or less unaltered, after a specified number of milliseconds, regardless of frequency. In this regard, it's identical to an ordinary delay or reverb pedal, which are also time-based synth effects, but the delays are short (closer to reverbs than full delay pedals) and like the phaser, flangers include a modulator which varies the timespan of the delay, and the rate of change of that delay, producing a sweeping cyclical effect to the sound.