If it would be so easy, Captcha never was invented.
I can easily crack your code and write a function, which bypasses it like it would be a human. Your suggestion means nothing in automated spam programs world.
The POST string which such kind of program needs to pass, may look something like that:
Knowing secret phrase program needs to verify, and URL variable under which it needs to be passed, there's nothing genious to work around this.
By the way, the second mistake in your code is that it will work only when PHP's setting register_globals is set to ON. It should use $_POST array. In most common configurations nowadays, register_globals is set to OFF. But this doesn't really matter, because your solution is weak, anyway.
Most common Captcha solutions, including our own
, are working different way. Secret phrase can not be read from source code, but is stored in a session. That way automated programs have no chances to read it and emulate it. This is still the only one way to fight automatic spam.