Page 1 of 1

how to redirect?

Posted: Thu Sep 20, 2007 12:21 am
by m2babaey
Hi
I need to redirect to the advertiser's website after some analysis. but header is not working
i use another tag that sometimes works and sometimes not:

Code: Select all

echo "<script> window.parent.ifrmTEXTFRNewWin('$url')</script>";
is there a solution? i'm still having problem. the original code is:
searchclicks.php:

Code: Select all

<?php
include 'global.php';
$keyword=$_SESSION['q'];
$publisher=clean($_GET['publisher']);
$advertiser=clean($_GET['advertiser']);
$listing=clean($_GET['listing']);

$price=getcost($keyword,$listing);

$sql2="SELECT * FROM advertiser WHERE id='$advertiser' ";
$result2=mysql_query($sql2) or die (mysql_error());
$row2=mysql_fetch_array($result2);
$advertiserbalance=$row2['balance'];
if ($advertiserbalance<$price) echo "The advertiser does not have enough balance in his/her account";
else{
$advertiserbalance-=$price;
$sql3="SELECT * FROM publisher WHERE id='$publisher' ";
$result3=mysql_query($sql3) or die (mysql_error());
$row3=mysql_fetch_array($result3);
$publisherbalance=$row3['balance'];
$price=$price*3/4 ;
$publisherbalance+=$price;
$sqlu1= "UPDATE advertiser SET balance='$advertiserbalance' WHERE id='$advertiser'";
$resultup1=mysql_query($sqlu1) or die(mysql_error()) ;
if (!$resultup1) echo "There was a problem during the analysis. Please contact us to inform aout the issue";
else{
$sqlu2= "UPDATE publisher SET balance='$publisherbalance' WHERE id='$publisher'";
$resultup2=mysql_query($sqlu2) or die(mysql_error()) ;
$sql4="SELECT * FROM listing WHERE id='$listing' ";
$result4=mysql_query($sql4) or die (mysql_error());
$row4=mysql_fetch_array($result4);
$url=$row4['url'];
//var_dump($row4);

//header("Location : $url");
//header('Location: '.$url); 
echo "<script> window.parent.ifrmTEXTFRNewWin('$url')</script>";
}
}
?>

Posted: Thu Sep 20, 2007 12:36 am
by maliskoleather
why cant you use

Code: Select all

header('Location: '.$url);

Posted: Thu Sep 20, 2007 12:51 am
by ReDucTor
maliskoleather, he said he was using that but it wouldnt work.

m2babaey, is the message you get headers already sent? if so look at where they are already sent, and fix it.

Posted: Thu Sep 20, 2007 1:29 am
by kreoton
You should use

Code: Select all

header('location:' .$url);
if you get error that headers already sent move header up to the script, because code after header() function is not stopped ;)

Posted: Thu Sep 20, 2007 1:34 am
by s.dot
Some things..

If you're using a closing php tag (?>) in your include file, make sure there's no space or new lines after it.
What's your URL look like that you're trying to go to?
Make sure to call exit or die after you send the header (otherwise your script tag will run and mess up the header() call)

Posted: Thu Sep 27, 2007 12:03 am
by m2babaey
none of above worked
please visit this link tho see what happens and click on one of the ad links:
http://www.php.jothost.com/adsense/test.php
I need something to move the page out of the iframe. in that page i'm using header( 'Location: ' .$url ) ; other codes didn't work though

Posted: Thu Sep 27, 2007 1:08 am
by Zeyber
Use this:

echo '<script> location.href = "location.html"; </script>';

Its a Java code

Posted: Thu Sep 27, 2007 1:27 am
by m2babaey
Zeyber wrote:Use this:

echo '<script> location.href = "location.html"; </script>';

Its a Java code
that's loading the destination url in the iframe again. in addition, how do i write the code with $url instead of location.html to avoid parse errors?
how can i load the page in full screen?