I finally figured out why I'm getting that error after putting that code inside an if statemant, but I still don't know how to fix it so it works.
If called from within a function, the return() statement immediately ends execution of the current function, and returns its argument as the value of the function call. return() will also end the execution of an eval() statement or script file.
Can somebody show me how to fix that script so that it can be put inside an if statement so I can use it with a form. I would greatly appreciate it.