I set up a class as a trial. I have 7 files in my project right now. I want to make them into 2 files. an index file and a class_lib file. So I set up my first class as a trial and it seems to be working, but there is a problem in my code. I don't get any errors right now, but what I think should happen isn't happening. I have a form that asks your name, when you put it in and press submit, it ads the name to a list. All is good. So now I want to add some validation. So I set up an error class as a test run.

Code:
class error {
	var $error = "You must put in a name";
	var $good = "good work, name has been entered";
function myError(){
	$pattern = '/[A-Za-z]+/';

 
	if(isset($_POST['go']) && !empty($_POST['name']) && preg_match($pattern, $_POST['name']))
	{
  		return $this->good;
	}
	else
	{
		return $this->error;
	}
}
}
my issue is that when I run the index page to view the form, the $error code is already visible in the div. It doesn't wait for me to put in a name or to match the $pattern. What is wrong with my logic here? I am calling the class in my index like this
Code:
<div>
<?php 
      $errorCode = new error();
      echo $errorCode->myError();
?>
</div>
thanks for your help