if u store the url your visitor on in the session or something, and then have avalable in $previous_url variable (just an example) then u could redirect by using:
Header("Location: ".$previous_url);
ofcourse u should update current url at the end of your script, so this way u would have "previous" url, not the current one, during the entire script.