Hello, my script is giving me headache for two days. I have a paid to click site, when user clicks on paid links my script displays surf page, where i have a timer and an iframe that displays sponsored site below the timer. After the timer loads users have to pass captcha and after that success icon shows up. I wanted to change this success icon into redirecting to sponsored site and braking my frame.

So far i am very close but i'm bad at javascript and php so i probably have some noob mistakes.

View.php is the page where users see timer and iframe, in visit.php hides all code that displays captcha, error icon, success icon, credits user's acccount...

This is the last part of visit.php that displays success icon after user clicked right captcha code:

// HOORAY! SUCCESS!
echo <<<EOT
document.getElementById('timer').setAttribute('class','success');
document.getElementById('timer').innerHTML='Success!';
EOT;
destroy();
?>

I tried to put this:

// HOORAY! SUCCESS!
echo <<<EOT
window.location= "<?php echo $ad_row['url']; ?>";
EOT;
destroy();
?>

because <?php echo $ad_row; ?>, displays the real link of sponsored ad (it's used for iframe) in view.php, but ofcorse it doesn't work....

there were these functions in view.php that I copied to visit.php but it didn't help:

$ad_id=limpiar($_GET["ad"]);
	$ad_result=mysql_query("SELECT * FROM ads WHERE id='$ad_id'");
    $ad_row=mysql_fetch_array($ad_result);

I don't know how to put another echo in echo :D :D
Can you plase solve these i tried googling for hours but no luck :(

Thank you a lot!

You don't have to reopen the php tags in a heredoc (heredoc is the EOT thing you're using).

So if $ad_row['url'] contains the url, you can just include it as you would any other variable in php:

// HOORAY! SUCCESS!
echo <<<EOT
window.location= "{$ad_row['url']}";
EOT;
destroy();
?>

The curly braces are for the array value.
My source for heredoc info is http://www.hudzilla.org/php/2_6_3.php.

(Tell me if this worked.)

Oh thank you a lot!!!

It is redirecting properly, but to view.php?ad=xxx again, i hope i will solve that by myself.

Thank you again!

Hm... it is weird what happens now....
I have this in view.php:

<iframe src="<?php echo $ad_row['url']; ?>" border="0" framespacing="0" marginheight="0" marginwidth="0" vspace="0" hspace="0" frameborder="0" height="100%" scrolling="yes" width="100%" id="site"></iframe>

And when i view page source in firefox i can see the real url of advertiser, but when i added this to visit.php it redirects to mydomain.com/view.php?ad=xxx again, not the real url. Maybe I need something to brake frame? Can you or someone help with this?

Thanks in advance, a lot!

Hey, i found the problem, i was missing this:

$ad_row=mysql_fetch_array($ad_result);

Thank you kanaku for solving this!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.