Thanks Mce - that works great.
Question 1: should my ob_start() come BEFORE session_start()? Also, does setting ob_start() have any other implications that might mess up my scripts' behavior?
Question 2: This is the tricky question. There are two buttons on my page, both of which need to submit the form. One button submits, processes the form and loads the rest of the original page. The other button submits, processes the form and then switches to a different page.
Easy enough to wrap an if($POST['redirect']) around the page switch so it only occurs if the $redirect variable is present. But - how to know which button was clicked?
Both buttons are images which submit the form "onClick":
<href="doesntmatter" onClick="document.myForm.submit(); return false;">
(plus a bunch of onMouseover stuff, etc.)
The href is ignored, thanks to the "return false;". If I remove the "return false;" either the href is still ignored, or the page jumps to that URL and the form doesn't get submitted. So the return false stays.
I tried adding a second javascript action to the "onClick" as follows:
<script>
function setRedirect() {
document.myForm[redirect].value = "true";
}
</script>
<input type="hidden" name="redirect" value="">
<href="doesntmatter" onClick="setRedirect(); document.myForm.submit(); return false;">
This should set the hidden field's value to "true" which will cause the redirect to occur once processing is complete.
But - now when I click on the button, I get directed to "doesntmatter" - i.e. my return false; isn't working anymore. I tried adding another return false; after setRedirect();, but it doesn't help.
Any suggestions as to how to do this?