The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

help with class

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.

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

I tried that and it does not work. I do not understand why. I have it set up to display an error if you do not put in a name and to display a success code if you do put in a name. But when I push the submit button, nothing shows up.

The form is on an index page. The code that I am working on is in a file I called error.php. Then I used a php include in the header of the index to include the error.php. the action of the form is in a file I called insert.php. So when you push the submit button, it goes to the action page, then I have a line in there that brings me back to the index page like this