How do I stop the little "OK" from appearing when I run a PHP on a custom button?

I have created a custom button and written some PHP code to go with it. I populate a few local variables and then run:

sc_exec_sql($insert_sql);

Everything works correctly. Except there is one really annoying thing… when the user clicks the button, the screen goes blank, and there is nothing on it except a little “OK” button. The user has to click the OK button, and the ScriptCase page comes back, showing the change to the underlying record (which is correct).

I have changed the setting “Reload quantity of records” from No to Yes and back, and it makes no difference.

I need this PHP to run without the OK button appearing. Thanks in advance.

use a sc_exit(ref) or similar or use sc_redir as the last statement in your event code.

Or use an ajax button