The OP provided his solution on pastebin, which I reproduce below (it is correct).
A better way to obtain the same result would be to recall that the directional derivative is the dot product with the gradient. The gradient of the norm being $\dfrac{\vec r_1-\vec r_2}{r_{12}}$, we obtain $$\frac{\vec r_1}{r_1}\cdot \frac{\vec r_1-\vec r_2}{r_{12}}$$
which is the same answer.
\begin{align*}
\frac{\partial}{\partial r_1} r_{12}
&= \frac{\partial}{\partial r_1} \sqrt{(x_1 - x_2)^2 + (y_1 - y_2)^2 + (z_1 - z_2)^2} \\
&= \frac{\partial}{\partial r_1} \sqrt{(r_1\sin\theta_1\cos\phi_1 - x_2)^2 + (r_1\sin\theta_1\sin\phi_1 - y_2)^2 + (r_1\cos\theta_1 - z_2)^2} \\
&= \left(\frac{1}{2r_{12}}\right) \frac{\partial}{\partial r_1} \Big[ (r_1\sin\theta_1\cos\phi_1 - x_2)^2 + (r_1\sin\theta_1\sin\phi_1 - y_2)^2 + (r_1\cos\theta_1 - z_2)^2 \Big] \\
&= \frac{1}{2r_{12}} \Big[ 2(x_1 - x_2)(\sin\theta_1\cos\phi_1) + 2(y_1 - y_2)(\sin\theta_1\sin\phi_1) + 2(z_1 - z_2)(\cos\theta_1) \Big] \\
&= \frac{1}{r_{12}} \left[ (x_1 - x_2)\frac{x_1}{r_1} + (y_1 - y_2)\frac{y_1}{r_1} + (z_1 - z_2)\frac{z_1}{r_1} \right] \\
&= \frac{1}{r_1 r_{12}} \Big[ r_1^2 - x_1x_2 - y_1y_2 - z_1z_2 \Big] \\
&= \frac{1}{r_1 r_{12}} \Big[ r_1^2 - \vec r_1 \vec r_2 \Big] \\
\end{align*}
What the OP has given as the electric fields inside and outside the sphere are only the magnitudes of these fields, as has been emphasized in other comments and answers. I suspect that those expressions were derived using Gauss' Law, which relied on spherical symmetry to assume two things: (i) that the field at a point with position vector $\vec{r}$, a distance $r = |\vec{r}|$ from the center of the sphere, depended only on this distance, and (ii) that the field was directed radially outward from the center of the sphere along the unit vector $\hat{r} = \vec{r}/r$. So the electric field vector is a piecewise continuous function of the radial coordinate $r$ alone, with direction $\hat{r}$, given by
$$\begin{align}\vec{E}(r) \,=\, \begin{cases}~~\vec{E}_{in}(r) = \dfrac{q}{R^3}\,r\,\hat{r}, ~~~ r \leq R, \\ \\~~ \vec{E}_{out}(r) = \dfrac{q}{r^2}\,\hat{r}, ~~~ r \geq R, \end{cases}\end{align}$$ where I am writing $$q = \dfrac{Q}{4\pi\epsilon_0}$$ for convenience. Since $\vec{E}(r)= -\nabla \phi(r)$ depends only on the radial coordinate $r$, it reduces to $$\vec{E}(r) = -\dfrac{d\phi}{dr}(r)\,\hat{r}.$$ The negative derivative of the scalar function $\phi(r)$ with respect to $r$ thus gives the radial (and only) component of $\vec{E}$, so from the piecewise expressions for the electric field we find the piecewise expressions for the derivative of $\phi$: $$\begin{align}-\dfrac{d\phi}{dr} = \begin{cases}~~\dfrac{q}{R^3}\,r, ~~~ r \leq R, \\ \\~~ \dfrac{q}{r^2}, ~~~ r \geq R, \end{cases}\end{align}$$ The indefinite integral of each side in the two cases gives $$\phi(r) = -\int\dfrac{q}{R^3}\,r\,dr = - \dfrac{q}{R^3}\dfrac{r^2}{2} + C_1, ~~~~r \leq R,$$ and $$\phi(r) = -\int\dfrac{q}{r^2}\,dr = \dfrac{q}{r} + C_2, ~~~~r \geq R.$$ In the second expression with $r \geq R$, in order for the potential to vanish as $r \to \infty$, we must set the integration constant $C_2 = 0$, hence $$\phi(r) = \dfrac{q}{r}, ~~~~r \geq R.$$ In order for the potential to be continuous at $r = R$, the potentials must be equal at the boundary: $$-\dfrac{q}{R^3}\dfrac{R^2}{2} + C_1 = \dfrac{q}{R},$$ from which we find $$C_1 = \dfrac{3q}{2R}.$$ The scalar potential is thus given by the piecewise continuous function $$\begin{align}\phi(r) \,=\, \begin{cases}~ -\dfrac{q}{R^3}\dfrac{r^2}{2} + \dfrac{3q}{2R}, ~~~r \leq R,\\ \\~~ \dfrac{q}{r}, ~~~r \geq R.\end{cases}\end{align}$$ In terms of $q = Q/4\pi\epsilon_0$, these are $$\begin{align}\phi(r) \,=\, \begin{cases}~~-\dfrac{Q}{8\pi\epsilon_0 R^3}\,r^2 + \dfrac{3Q}{8\pi\epsilon_0 R}, ~~~r \leq R,\\ \\ ~~\dfrac{Q}{4\pi\epsilon_0 r}, ~~~r \geq R.\end{cases}\end{align}$$
Best Answer
Well, if you consider $x_i\frac{\partial z}{\partial z}+z\frac{\partial x_i}{\partial z}$, we can immediately see that $\frac{\partial z}{\partial z}=1$, since intuitively, z changes at the same rate as itself. Symbolically, we could write that $\frac{\partial x_k}{\partial x_l}=\delta^k_l$, where $\delta^k_l=1$ when $k=l$ and $0$ otherwise.
Now, it was explicitly stated that $z$ does not depend on $x$, therefore $\frac{\partial z}{\partial x_i}=0$. As $z$ does not depend on $x_i$, the converse is also true; namely, $x_i$ does not depend on $z$, since else you could express $z$ in terms of $x_i$, which would contradict the initial assumption. Hence, $\frac{\partial x_i}{\partial z}=0$. This implies that regardless of the value of $z$, the second term is zero.