Well, I see a few errors.
/r/n should be \r\n
I think the main problem is undefined variables:
Add this before if(!$error)
$error = false;
foreach($_POST as $key => $value) {
$$key = trim(strip_tags($value));
if(empty($$key)) $error = true;
} else $error = false;
second is this...