Bifunctional enzyme that catalyzes the formation of dihydropteroate, the immediate precursor of folic acid and the reduction of dihydropteroate to tetrahydropteroate. (7,8-dihydropterin-6-yl)methyl diphosphate + 4-aminobenzoate = 7,8-dihydropteroate + diphosphate (6S)-5,6,7,8-tetrahydropteroate + NAD(+) = 7,8-dihydropteroate + H(+) + NADH Binds 1 FAD or 1 FMN per subunit. Cofactor biosynthesis; tetrahydrofolate biosynthesis; 7,8-dihydrofolate from 2-amino-4-hydroxy-6-hydroxymethyl-7,8-dihydropteridine diphosphate and 4-aminobenzoate: step 1/2. The N-terminal extension of FolP is essential for the reducing activity and binds FMN. FolP can complement an E.coli strain in which the two distinct genes encoding dihydrofolate reductases folA and folM are deleted. In the C-terminal section; belongs to the DHPS family.