Javascript Redirect Question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
patriotofgod
Forum Newbie
Posts: 4
Joined: Sat Dec 13, 2008 6:36 pm

Javascript Redirect Question

Post by patriotofgod »

Hi, I have put a small php code on a website so that when I access the website, it will redirect me to a second website.

Code: Select all

 
<?php
 
$site2 = "http://www.google.com";
 
echo "<body onload="javascript&#058;frmClickTracking.submit();">";
echo "<form action="" . $site2 . "" method="post" name="frmClickTracking">";
echo "</form>";
 
?>
 
<body>
</body>
</html>
 
Why is this code not working?
Last edited by patriotofgod on Sun Dec 14, 2008 10:12 am, edited 1 time in total.
patriotofgod
Forum Newbie
Posts: 4
Joined: Sat Dec 13, 2008 6:36 pm

Re: Javascript Redirect Question

Post by patriotofgod »

When I access the page, it just keeps trying to reload. I can really use the help, thanks.
cavemaneca
Forum Commoner
Posts: 59
Joined: Sat Dec 13, 2008 2:16 am

Re: Javascript Redirect Question

Post by cavemaneca »

Code: Select all

<?php 
  $site2 = "http://www.google.com";
 
?>
 
  <body onload="javascript&#058;frmClickTracking.submit();">
    <form action="<?php echo $site2; ?>">
    </form>
 
  </body>
</html>
Either use this or make sure you escape all of the quotation marks like you should be doing.
Also, one body tag is enough. I don't see why you needed two. And Google doesn't allow POST to their website, so trying to track clicks or whatever you are doing and sending a name won't do anything.
Post Reply