$redirect and $ref will hold null values unless you set them. And if you don't set them the same, then there is a chance to get an error. I don't see in your code where you set 1 as the other
$ref = $redirect;
// OR
$redirect = $ref;
Perhaps I'm missing something..... but...
You are changing your code as you go, so I don't really follow. What I had originally posted works. Why are you creating two variables to hold the same information? Use one or the other, $ref or $redirect. No use in using more than one veriable to hold identical information, catch my drift?
The reason I say you are changing yoru code is because in your original post, I don't see:
<?php
$ref = $_SERVER['HTTP_REFERER'];
?>
So, if you want help, yes you need to work at it yourself, but don't change code and not post the changed code, cuz I just got lost trying to find it.
If what you're trying to do is just set $ref & $redirect to be the same, then use only 1 of them, and then change your code as you see fit.
BUT in your original code, I still do NOT see how you are calling the php variable $ref/$redirect from the HTTP Form. You MUST request that value, or you can't get it.
I hope I can help you, but I'll be in and out this week. If you use my original posting of the form & php, it will work.
~Brett