The argument below is outlined in exercises 5.6-5.8 on p.63 of Ireland & Rosen's A Classical Introduction to Modern Number Theory 2nd Ed.
- Show that the number of solutions to $x^2-y^2\equiv a(p)$ is given by
$$\sum_{y=0}^{p-1}(1+((y^2+a)/p)).$$
- By calculating directly show that the number of solutions to $x^2-y^2\equiv a(p)$ is $p-1$ if $p\not\mid a$ and $2p-1$ if $p\mid a$. ($\textit{Hint}$: Use the change of variables $u=x+y,v=x-y$.)
- Combining the results of Exercises 6 and 7 show that
$$\sum_{y=0}^{p-1}\left(\frac{y^2+a}{p}\right)=\begin{cases}-1,\text{if }p\not\mid a,\\p-1,\text{ if }p\mid a.\end{cases}$$
If $y$ is such that $y^2+a\equiv0(p)$, then $x^2-y^2\equiv a(p)$ has exactly one solution, namely $x\equiv0(p)$. If $y$ is such that $y^2+a\not\equiv0(p)$, then $x^2-y^2\equiv a(p)$ either has no solutions or if it has a solution, then it has exactly two solutions. In any case, for each $y$, the number of solutions to $x^2-y^2\equiv a(p)$ is $1+((y^2+a)/p)$. So the number of solutions to $x^2-y^2\equiv a(p)$ is given by $\sum_{y=0}^{p-1}(1+((y^2+a)/p))$.
Let $u=x+y$ and $v=x-y$. Then $x^2-y^2\equiv a(p)$ is equivalent to $uv\equiv a(p)$. Suppose $p\not\mid a$. Then we must have $u,v\not\equiv0(p)$. So for each $u$, $v$ is uniquely determined by $v\equiv u^{-1}a(p)$. There are $p-1$ such pairs of $u,v$. Suppose $p\mid a$. If $u\equiv0(p)$, then $v$ can be any of the $p$ elements. But if $u\not\equiv0(p)$, then we must have $v\equiv u^{-1}0\equiv0(p)$. So there are $p+(p-1)=2p-1$ such pairs of $u,v$. Since each pair of $x,y$ is uniquely determine by a pair of $u,v$ and vice versa, we see that the number of solutions to $x^2-y^2\equiv a(p)$ is $p-1$ if $p\not\mid a$ and $2p-1$ if $p\mid a$.
Now, $\sum_{y=0}^{p-1}(1+((y^2+a)/p))=p+\sum_{y=0}^{p-1}(y^2+a)/p)$. If $p\not\mid a$, then $\sum_{y=0}^{p-1}(1+((y^2+a)/p))=p-1$, so $\sum_{y=0}^{p-1}(y^2+a)/p)=-1$. If $p\mid a$, then $\sum_{y=0}^{p-1}(1+((y^2+a)/p))=2p-1$, so $\sum_{y=0}^{p-1}(y^2+a)/p)=p-1$. Hence
$\sum_{y=0}^{p-1}\left(\frac{y^2+a}{p}\right)=\begin{cases}-1,\text{if }p\not\mid a,\\p-1,\text{ if }p\mid a.\end{cases}$
We may use the above result to derive a formula for the more general sum $\sum_{x\in\Bbb F_p}\left(\frac{ax^2+bx+c}{p}\right)$, where $p$ is an odd prime and $a,b,c\in\Bbb F_p$.
If $a=0,b=0$, then $\sum_{x\in\Bbb F_p}\left(\frac{ax^2+bx+c}{p}\right)=\sum_{x\in\Bbb F_p}\left(\frac{c}{p}\right)=p\left(\frac{c}{p}\right)$.
If $a=0,b\neq0$, then $\sum_{x\in\Bbb F_p}\left(\frac{ax^2+bx+c}{p}\right)=\sum_{x\in\Bbb F_p}\left(\frac{bx+c}{p}\right)=0$, as explained here.
Suppose $a\neq0$. Then
\begin{align*}
\sum_{x\in\Bbb F_p}\left(\frac{ax^2+bx+c}{p}\right)&=\left(\frac{4a}{p}\right)\sum_{x\in\Bbb F_p}\left(\frac{4a^2x^2+4abx+4ac}{p}\right)\\
&=\left(\frac{a}{p}\right)\sum_{x\in\Bbb F_p}\left(\frac{(2ax+b)^2-(b^2-4ac)}{p}\right)\\&=\left(\frac{a}{p}\right)\sum_{y\in\Bbb F_p}\left(\frac{y^2-(b^2-4ac)}{p}\right).
\end{align*}
If $b^2-4ac=0$, then
\begin{align*}\sum_{x\in\Bbb F_p}\left(\frac{ax^2+bx+c}{p}\right)
&=\left(\frac{a}{p}\right)\sum_{y\in\Bbb F_p}\left(\frac{y^2}{p}\right)\\
&=(p-1)\left(\frac{a}{p}\right),
\end{align*}
where the last equality follows since $\left(\frac{y^2}{p}\right)=0$ for $y=0$ and $\left(\frac{y^2}{p}\right)=1$ otherwise. Alternatively, one could apply directly the result in the beginning.
If $b^2-4ac\neq0$, then
\begin{align*}\sum_{x\in\Bbb F_p}\left(\frac{ax^2+bx+c}{p}\right)
&=\left(\frac{a}{p}\right)\sum_{y\in\Bbb F_p}\left(\frac{y^2-(b^2-4ac)}{p}\right)\\
&=-\left(\frac{a}{p}\right),
\end{align*}
where the last equality follows from the result in the beginning.