Solved

background process in php

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

708 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now