Solved

background process in php

Posted on 2004-10-13
4
220 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

786 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