943,812 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 478
  • PHP RSS
Dec 29th, 2008
0

Problems with redirecting...please help

Expand Post »
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:

PHP Syntax (Toggle Plain Text)
  1. // HOORAY! SUCCESS!
  2. echo <<<EOT
  3. document.getElementById('timer').setAttribute('class','success');
  4. document.getElementById('timer').innerHTML='Success!';
  5. EOT;
  6. destroy();
  7. ?>

I tried to put this:

PHP Syntax (Toggle Plain Text)
  1. // HOORAY! SUCCESS!
  2. echo <<<EOT
  3. window.location= "<?php echo $ad_row['url']; ?>";
  4. EOT;
  5. destroy();
  6. ?>

because <?php echo $ad_row['url']; ?>, 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:

PHP Syntax (Toggle Plain Text)
  1. $ad_id=limpiar($_GET["ad"]);
  2. $ad_result=mysql_query("SELECT * FROM ads WHERE id='$ad_id'");
  3. $ad_row=mysql_fetch_array($ad_result);

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

Thank you a lot!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
masterOFwww is offline Offline
8 posts
since Dec 2008
Dec 29th, 2008
0

Re: Problems with redirecting...please help

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:

PHP Syntax (Toggle Plain Text)
  1. // HOORAY! SUCCESS!
  2. echo <<<EOT
  3. window.location= "{$ad_row['url']}";
  4. EOT;
  5. destroy();
  6. ?>

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.)
Reputation Points: 70
Solved Threads: 15
Posting Whiz
kanaku is offline Offline
378 posts
since Jan 2007
Dec 29th, 2008
0

Re: Problems with redirecting...please help

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!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
masterOFwww is offline Offline
8 posts
since Dec 2008
Dec 29th, 2008
0

Re: Problems with redirecting...please help

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

PHP Syntax (Toggle Plain Text)
  1. <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!
Last edited by masterOFwww; Dec 29th, 2008 at 6:29 pm.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
masterOFwww is offline Offline
8 posts
since Dec 2008
Dec 29th, 2008
0

Re: Problems with redirecting...please help

Hey, i found the problem, i was missing this:
PHP Syntax (Toggle Plain Text)
  1. $ad_row=mysql_fetch_array($ad_result);

Thank you kanaku for solving this!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
masterOFwww is offline Offline
8 posts
since Dec 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: mssql,sqlsrv,obdc_connect
Next Thread in PHP Forum Timeline: multiple images





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC