Showing that $|g(x)| \leq M$ I was working on the following problem

Let $\{g_{k}\}_{k=1}^{\infty}$ be a sequence of continuous real-valued functions on $[0,1]$. Assume that there is a number $M$ such that $|g_{k}(x)| \leq M$ for every $k$ and every $x \in [0,1]$ and also there is a continuous real-valued function $g$ on $[0,1]$ such that 
  $$ \int^{1}_{0} g_{k}(x)p(x)dx \to \int^{1}_{0} g(x)p(x)dx$$
  as $k \to \infty$ for every polynomial $p$. Prove that $|g(x)| \leq M$ for every $x \in [0,1]$ and that
  $$ \int^{1}_{0} g_{k}(x)f(x)dx \to \int^{1}_{0} g(x)f(x)dx$$ for every continuous $f$. 

I am having trouble showing $|g(x)| \leq M$
I was able to show that $ \int^{1}_{0} g_{k}(x)f(x)dx \to \int^{1}_{0} g(x)f(x)dx$ assuming that $|g(x)| \leq M$. I did this by estimating
$$E= \vert \int^{1}_{0} g_{n}(x)f(x)dx- \int^{1}_{0} g(x)f(x)dx \vert$$. We then have by the triangle inequality that 
$$
E \leq E_{1}+ E_{2}
$$
where 
\begin{align*}
E_{1} &=  \vert \int^{1}_{0} g_{n}(x)p_{k}(x)dx - \int^{1}_{0} g_{n}(x)f(x)dx \vert \\
E_{2} &= \vert  \int^{1}_{0} g_{n}(x)f(x)dx-\int^{1}_{0} g(x)f(x)dx \vert \\
\end{align*}
I can make $E_{1}$ "small" using the Stone-Weierstrass Theorem, but to make $E_{2}$ "small", I needed to assume that $|g(x)| \leq M$. 

I don't quite follow how you split things into two terms. Seems to me the natural thing is
$$|\int g_nf-\int gf|\le|\int g_nf-\int g_np_k|+|\int g_np_k-\int gp_k|+|\int gp_k-\int gf|=E_1+E_2+E_3.$$
Now. You're given that $g$ is continuous. So there exists $N$ such that $|g|\le N$. This works just as well as if you already knew $|g|\le M$. Suppose $p_k\to f$ uniformly. If $k$ is large enough then $E_1<\epsilon$ for all $n$ and if $k$ is large enough then $E_3<\epsilon$ for all $n$. Now fix $k$ "large enough" that both those conditions are satisfied; if $n$ is large enough then $E_2<\epsilon$.
So that gives a proof that $\int g_nf\to\int gf$ for every continuous $f$.
This implies that $|\int gf|\le M \int|f|$ for  every continuous $f$. And it follows from that (leaving something for you) that $|g|\le M$.
