How can I redirect the visitor to the last page the user came from using header() (or something else)?
Ok, well, you already posted this, but you want to just send em back where they came from, do this
<body onLoad="history.back(-1);">
I don't think that will work because the body tag is already used way before the PHP started. But I will give it a try.
If you use the referred URL global variable in the header statement I think that would work.
But you'd need to call header() before any other output. Sounds like you're ouputting things before redirecting. Plus, PHP's refferer is unreliable