redirecting to a page url in php
<p>I have folowing code in which i am using some conditions on page to be open or redirected to any other url but php method for calling a url is not working here please any one help me how to get out of this issue
here is my php code</p>

<pre><code>&lt;?php

$good_domains = array("http://172.17.0.221:84/cp.aspx","http://172.17.0.221:84/cp.aspx");
if(!in_array($_SERVER['HTTP_REFERER'],$good_domains)){
echo "&lt;script&gt;alert(\"NO\");&lt;/script&gt;";
Redirect('http://www.google.com.pk');
}
else{
echo "&lt;script&gt;alert(\"YES\");&lt;/script&gt;";
//echo $_SERVER['HTTP_REFERER'];
//Redirect('http://www.shakarganj.com.pk');

$URL="http://www.google.com"; 

header ("Location: $URL");
}

?&gt;
</code></pre>

<p>When i run the page the folowing error is generated.</p>

<pre><code>Warning: Cannot modify header information - headers already sent by (output started at C:\xampplite\htdocs\a\sfpl\MT.php:9) in C:\xampplite\htdocs\a\sfpl\MT.php on line 15
</code></pre>
