This question is a follow-up to http://mathoverflow.net/questions/75329/when-does-the-relative-differential-df0-imply-that-f-comes-from-the-base.  There it was asked, for an $A$-algebra $B$, under what conditions does $df=0$ (in the module of relative differentials $\Omega_{B/A}$) imply that $f$ is ``constant", i.e. lies in $A$.  The answer relied on a characteristic 0 assumption.  My question is about rings $A$ in which $p=0$ for a prime $p$.

Assume that $p=0$ in $A$.  Let's also assume that $A$ is perfect in the sense that $A^p=A$.  I don't want to assume, however, that $A$ is integral or even reduced.  Let $B$ be an $A$-algebra.  Let $f\in B$ be such that $df=0$ in $\Omega_{B/A}$.  

> Under what conditions on $A$ and $B$ may we deduce that $f\in B^p$?

Notice that the converse is always true, because $d(f^p)=pf^{p-1}df=0$.  Also notice that if $f\in A$, then of course $df=0$, but by our hypothesis on $A$ we have $f\in A=A^p\subset B^p$.  

The conclusion is true, for instance, when $B$ is a polynomial ring over $A$, and also (I think) when $B$ is etale over $A$.