The weight hierarchy of a linear code have been an important research topic in coding theory since Wei’s original work in 1991. In this paper, choosing D={(x,y)∈(Fps1×Fps2)\{(0,0)}:f(x)+Tr1s2(αy)=0}α∈Fps2∗Fps1Fp as a defining set, where D={(x,y)∈(Fps1×Fps2)\{(0,0)}:f(x)+Tr1s2(αy)=0}α∈Fps2∗Fps1Fp, f(x) is a quadratic form over D={(x,y)∈(Fps1×Fps2)\{(0,0)}:f(x)+Tr1s2(αy)=0}α∈Fps2∗Fps1Fp with values in D={(x,y)∈(Fps1×Fps2)\{(0,0)}:f(x)+Tr1s2(αy)=0}α∈Fps2∗Fps1Fp and f(x) can be non-degenerate or not, we construct a family of three-weight p-ary linear codes and determine their weight distributions and weight hierarchies completely. Most of the codes can be used in secret sharing schemes.