Take out the echo calls, you can’t send information to the browser before the headers.
You can try something like this to still show if an error happens:
if(!$retval) {
echo "Unsuccessfull " . mysql_error();
}
solved Cannot modify header information [duplicate]