how to code a 'go back' button with rules on URL
<p>I am attempting to code a 'go back' button with the following rules</p>

<p>1) If the URL of current page is equal to URL of previous page, it does not replace the $_SESSION['goback'] url.</p>

<p>2) Only when the current page does not equal to the previous page, will the $_SESSION['goback'] url be replaced.</p>

<p>My current code...</p>

<pre><code>$previouspage = $_SERVER['HTTP_REFERER'];
$currentpage = 'http'.(empty($_SERVER['HTTPS'])?'':'s').'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
if ($currentpage != $previouspage) {
    $_SESSION['goback'] = $previouspage;
}
</code></pre>

<p>This is not working.  I'm trying to figure out why.  It was a last minute thought, so I'm sure I'm making a stupid mistake somewhere.  It keeps setting the $_SESSION['goback'] to the previous page even if the page url's are the same (after form submission).</p>

<p>The form</p>

<pre><code>&lt;form action="&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;" method="POST" enctype="multipart/form-data"&gt; 
  Upload File: &lt;input type="file" name="fileup" /&gt;&lt;br/&gt;
  &lt;input type="submit" name='submit' value="Upload" /&gt; 
 &lt;/form&gt;
</code></pre>
