First of all, why do you immediately close the Else block:
<?php
if ($submit) {
if ($text == "test") {
$error="N";
}else{
$error="Y";
}
} else {
}
?>
If you don't want to have an alternate code block, just omit the else block. If you're intention is to have the HTML after you end that php block display only if $text is not == "test", you omit that last }.
You should also change
echo"only "test" is a valid value";
to
echo "only \"test\" is a valid value";
Also, you should probably change references to form variables like $submit to $_POST['submit']; for better compatibility with future versions of php.