Redirect the user to another page

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
sathish
Forum Newbie
Posts: 4
Joined: Thu Jul 08, 2004 12:14 pm

Redirect the user to another page

Post by sathish »

Hi,
Using the Linux Cron I am trying to execute a php script , mypage.php .

The PHP page is fetching data from the mysql database . Using javascript I am trying to open a POP UP WINDOW for each records of the fetched data like destination URL, querystring etc.

While POP UP, the destination URL will trigger a mail functionality .(This is the requirement flow of my client :) )

For test purpose from the shell prompt of Linux , using command php mypage.php I am trying to execute the php page.

My problem is, the triggering function of the POP UP window is not called while testing. So I am not getting the test mail from the system. But the same php script is working while running in a browser.

I have tried using header redirection, javascript document.location and also javascript window.open(url) methods.

How can I make it to work in CRON? am I doing it in a wrong way while executing in shell? Whats about the Javascript running in CRON?
Please help me to correct this problem ASAP. Thanx in advance.


The sample code of mypage.php for your reference
-----------------------------------------------------------

Code: Select all

<html>
<head>
<script language='javascript'>
 function popClose()
 {
   if (newwindow) newwindow.close();
   //window.close();
  }

  function popitup(urlData)
 {
   newwindow=window.open(urlData);
  return false;
 }
 self.setTimeout('popClose();', 15000);
</script>
</head>
<body>
<?php
   $sql = " SELECT url,toEmail ....";
   rs = mysql_query($sql);  ....

   for($i=0;$i<$num_rows;$i++)
  {
     $scriptVar="http://".mysql_result($rs,i,0)."?email=".mysql_result($rs,i,1)."";

    print("<script language="JavaScript">popitup(".$scriptVar.");</script>");

     /*
print("<script language="JavaScript">document.location="".$scriptVar."";</script>");
    */    
  }

?>
</body>
<html>
Thanx & Regards,
Sathish


feyd | added

Code: Select all

tags[/color]
Last edited by sathish on Thu Jul 08, 2004 12:36 pm, edited 1 time in total.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

I really don't think you can. Opening a new window via Javascript is run client-side, and really doesn't have anything to do with PHP (except the fact it's output by PHP). So, running the PHP file on the command line will not execute the Javascript.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
sathish
Forum Newbie
Posts: 4
Joined: Thu Jul 08, 2004 12:14 pm

Post by sathish »

Thanx for your reply. I used javascript. I can use header redirection method . But I need to call the destination more than once. Is there any other way to execute the URL from the PHP script? and that will helpful to solve my situation?


Sathish
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

It doesn't look like you can make the same script run well in a both a browser and the command line. Why don't you just have your the file send an email right in the file, rather than loading up a new window.

Also, putting your code in [syntax=php][/syntax] tags makes it MUCH easier to read. :)
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
sathish
Forum Newbie
Posts: 4
Joined: Thu Jul 08, 2004 12:14 pm

Post by sathish »

Okay. Thanks for your reply.

Is it possible for me to execute/call the destination URL from the PHP apart from the methods what I have used above ?

So that will just trigger the URL from the php page running in the shell access. is there any solution?

Thanx & regards,
sathish
sathish
Forum Newbie
Posts: 4
Joined: Thu Jul 08, 2004 12:14 pm

Post by sathish »

Hi ,

From Tom I got a suggestion that I can use either include() function or else fopen() to achieve my requirement.

....but remember use complete URL http://domainname/path/to/file.php for this case.

Thanks a ton to Pickle and TommYNandA!!!!!

Sathizh
Post Reply