Well, in the short term;
Write a 'executed' code into the session; dont execute the code block if the session holds that value.
This is obviously easier to do with form input.
<input type='hidden' name='formid' value='<?php echo time(); ?>'>
$_SESSION[$_POST['formid']] = '';
If they push the back button (and thus, resubmit the form), $_SESSION will hold the value of formid already, and not execute the code.