Solved

background process in php

Posted on 2004-10-13
4
224 Views
Last Modified: 2006-11-17
Hello,   I have a screen that will be displaying a movie created for windows media player.  While this movie is running I need javascript to kick off a  background process to update the movie.  This could happen several times while the movie is running.  Can I write the background process in php?  will it popup a little window or can I write it completely in the background (preferable).  If I can not write it that way can I integrate a java file into the mix?  Lots of stuff to this question so I appreciate the help!
0
Comment
Question by:JGoyer
  • 2
  • 2
4 Comments
 
LVL 49

Expert Comment

by:Roonaan
ID: 12299019
What do you mean by "update the movie"? And why would this process happen frequently?

As you use javascript it is never a problem to call a php script in the background. It is just the question what it is you need the php script to do and how you want it to output its data.

There are a lot of ways:
- use process.php?ext=.png, let the script first return a png and then have it do some maintainance processing.
- use a iframe and call the script in there.
- let javascript add a <script src="somephp.php"></script> to the document contents and let the script return javascript output.

Please give us more details as to what it is you need.

-r-
0
 
LVL 2

Author Comment

by:JGoyer
ID: 12299176
More details:  The movie is to seperated out into multiple modules.  The viewer has the option of watching it in its entirety or stopping at somepoint.  We need to keep track of which modules they have completed so that when they come back to the movie they can go right back to where they were.  So, once they reach the end of module 1 javascript kicks off a call to a php process (how does it do that?) that process runs in a seperate window (output something like you have finished module one continue to module 2?) if they click yes the javascript window goes away and the next module starts up, if they click no they go to another screen.  The part about going on to the next mod in the same screen is pretty key also.  Thanks for you time and whatever you can come up with in this mess ;-)

JGoyer

ps what is an iframe?
0
 
LVL 49

Accepted Solution

by:
Roonaan earned 500 total points
ID: 12299417
An iframe is inline frame. And can be used to display another website into a rectangular display on a place you would like it to display.

Personally, I don't know how javascript is going to detect when the moviepart is stopped. But from that point on, it would be quite 'easy'. You would write a function in javascript like the one i'll write below:

<script type="text/javascript">
function run_php_window(currentmovieid)
{
    window.open('continue.php?movieid=' + currentmovieid, 'continueWindow', 'height=240,width=320');
}
</script>

Continue.php would then look something like this:
stage 1 is the stage where the visitor gets asked wether or not he would like to continue.
stage 2 is the stage where we will redirect the parent window.
<?php

$movieid = $_GET['movieid'];
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
 $stage = 2;
}
else
{
 $stage = 1;
}

if($stage == 1)
{
?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF'].'?movieid='.$movieid;?>">
<input type="submit" name="movie_next" value="Goto next module" />
<input type="submit" name="movie_stop" value="Call it a day" />
</form>
<?php
}
elseif($stage == 2)
{
 if(isset($_POST['movie_next']))
   $parenturl = 'url_of_next_module';
 else
   $parenturl = 'url_of_the_other_screen';
 ?>
 <html>
  <head>
   <title>Handling your request</title>
   <script type="text/javascript">
   function go()
   {
    window.opener.location.href="<?php echo $parenturl;?>";
    window.close();
   }
   </script>
  </head>
  <body onload="go();">
    You request will be handled appropriately. You will be directed to:
    <p><a target="_blank" href="<?php echo $parenturl;?>"><?php echo $parenturl;?></a>.</p>
    If redirection fails. Please click the link above and close this window.
  </body>
  </html>
<?php  
}
?>

This would give you a popup window asking what people want to do and then handling accordingly.

Regards

-r-
0
 
LVL 2

Author Comment

by:JGoyer
ID: 12322584
Thanks a ton!!
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How can I make this form submit to itself? 10 35
Help with PHP 13 27
IP 10.0.1.2 / 255.0.0.0 61 56
JQuery Search Filter 2 28
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question