Let F p be a finite field, where p is a prime. This paper presents a new construction of a code C over F p 2 from two linear codes over F p , which has F p -linearity and its minimum distance is equal to its minimum nonzero weight. Based on our construction, we shall determine the weight enumerators of some codes defined by quadratic bent functions and simplex codes. It will be shown that these codes have a few nonzero weights.