title: How can I get PHP redirect to work in a frame?
body: <p>I have a page that uses two frames, the top frame displays a username and the bottom frame displays that user's website. However, before the bottom frame displays the website it does some backend database work.</p>
  
  <p>Relevant code of main html (note: variables passed change with each refresh):</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
  &lt;META HTTP-EQUIV="Refresh" CONTENT="30"&gt;
  &lt;/head&gt;
  &lt;frameset rows="20%, 80%"&gt;
  &lt;frame src="search-results.php?user=&lt;?php echo $row['user'];?&gt;" name="content1"&gt;
  &lt;frame src="a3track.php?user=&lt;?php echo $row['user'];?&gt;&amp;url=&lt;?php echo $row['url'];?&gt;" name="content2"&gt;
  &lt;/frameset&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Relevant code of top frame page (search-results.php):</p>
  
  <pre><code>&lt;?php
  $user=$_GET['user'];
  echo '&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;' . $user . '&lt;/body&gt;&lt;/html&gt;';
  ?&gt;
  </code></pre>
  
  <p>Relevant code of bottom frame page (a3track.php):</p>
  
  <pre><code>&lt;?php
  $user=$_GET['user'];
  $url=$_GET['url'];
  // do some database work here
  //Then redirect to client's website
  $redirect_to = "http://" . $url;
  echo '&lt;script&gt;
  &lt;!--
  window.location = "'.$redirect_to.'"
  --&gt;
  &lt;/script&gt;';
  ?&gt;
  </code></pre>
  
  <p>What should happen is that the client's website appears in the bottom frame for 30 seconds but after doing the database work the frame remains blank.</p>
  
  <p>If I run the page a3track.php by itself in a stand-alone window it works, displaying the redirected website correctly after doing the database work, but it does not do that when inside the frame.</p>
  
  <p>I am guessing that something needs to be changed in the script part of a3track.php but I don't know what and cannot find any clues in the loads of sites and pages i have perused in search of an answer.</p>