Page 1 of 2
PHP and Flash [SOLVED]
Posted: Fri Dec 23, 2005 10:28 pm
by jts_01
I have a problem with a flash banner on top of my site that keeps reloading at every new page. So I made the page into two parts using php includes one part the header (where the flash is) and the other part into the page body. However, the flash still reloads. Any insight in how to keep the header from refreshing would be appreciated. Thanks.
This is the code that im using for the includes-
Code: Select all
<?php
$url=$_GET['url']; if (empty($url)) { $url='index'; }
changelocation($url);
function changelocation($url) {
echo '<table width="766" border="0" align="center" cellpadding="0" cellspacing="0">';
echo '<tr>';
echo '<table width="766" border="0" align="center" cellpadding="0" cellspacing="0">';
echo '<tr>';
echo '<td height="0">';
switch ($url)
{
case 'index':
include ('main.html');
break;
case 'hosting':
include ('hosting.html');
break;
case 'servers':
include ('servers.html');
break;
case 'about':
include ('about.html');
break;
case 'support':
include ('support.html');
break;
case 'membersarea':
include ('membersarea.html');
break;
}
echo '</td></tr></table>';
}
?>
Posted: Fri Dec 23, 2005 10:48 pm
by josh
Is the flash file actually re-downloading off the server, or is the movie just starting over?
Posted: Fri Dec 23, 2005 11:11 pm
by jts_01
I believe it's starting over or stored in the users cache.
Posted: Fri Dec 23, 2005 11:18 pm
by josh
The flash movie will start over since you are changing the page it is contained in, the only solution I can think of is frames
Posted: Fri Dec 23, 2005 11:32 pm
by Trenchant
Another solution could be using a session.
Code: Select all
<?php
if ($_SESSION['new_user'] == true) {
// The user has seen the initial banner. Don't show it again.
SHOW BANNER
} else {
// The user hasn't seen the initial banner. Show it.
SHOW INITIAL BANNER WITH INTRO OR WHATEVER
// Set the session value so that the user doesn't see this banner view again
$_SESSION['new_user'] = 'true';
}
That might be the solution you're looking for. The only downfall is that it requires two copies of your flash banner made. You could get the flash banner to check for a PHP value but that would be slower and use up more resources.
Posted: Sat Dec 24, 2005 4:17 am
by m3mn0n
PHP is server-side so you'll need a client-side solution to prevent a client from reloading a specific portion of the page.
eg.
-Using Frames
-AJAX
-Hidden divs & JavaScript
-Build it entirely in Flash
Posted: Sat Dec 24, 2005 3:26 pm
by jts_01
Another solution could be using a session.
PHP:
<?php
if ($_SESSION['new_user'] == true) {
// The user has seen the initial banner. Don't show it again.
SHOW BANNER
} else {
// The user hasn't seen the initial banner. Show it.
SHOW INITIAL BANNER WITH INTRO OR WHATEVER
// Set the session value so that the user doesn't see this banner view again
$_SESSION['new_user'] = 'true';
}
That might be the solution you're looking for. The only downfall is that it requires two copies of your flash banner made. You could get the flash banner to check for a PHP value but that would be slower and use up more resources.
Yea this more like what I'm looking for. I've created the two files but I'm kind of confused about how I should put my flash in where you say "show banner." Some example of this would really help. Thanks so far.
Posted: Sat Dec 24, 2005 9:49 pm
by josh
Code: Select all
if ($_SESSION['new_user'] == true) {
// The user has seen the initial banner. Don't show it again.
?>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="550" height="450">
<param name="movie" value="movie.swf" />
<param name="quality" value="high" />
<embed src="movie.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="550" height="450"></embed>
</object>
<?
} else {
just exit php and put the html in like that
Posted: Sat Dec 24, 2005 10:17 pm
by Jenk
use isset() as well to avoid getting notice errors.
Code: Select all
if ((isset($_SESSION['new_user'])) && ($_SESSION['visited'] === true)) {
//user has visited site with this session..
} else {
//user has not
}
Posted: Sat Dec 24, 2005 10:38 pm
by Jenk
http://uk.php.net/session
Have a read on how to use sessions.
And please use PHP tags when posting php code.
Posted: Sat Dec 24, 2005 11:02 pm
by jts_01
It doesn't seem to work. After I refresh the browswer it only displays the cougar_1.swf. No erros are displayed nor have I found any in the log.
This is the code I have now-
Code: Select all
<?php
if ((isset($_SESSION['new_user'])) && ($_SESSION['visited'] === true)) {
// The user has seen the initial banner. Don't show it again.
?>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="510" height="205">
<param name="movie" value="flash/cougar1_re.swf">
<param name="quality" value="high">
<embed src="flash/cougar1_re.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="510" height="205"></embed>
</object>
<?php
} else {
?>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="510" height="205">
<param name="movie" value="flash/cougar1_.swf">
<param name="quality" value="high">
<embed src="flash/cougar1_.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="510" height="205"></embed>
</object>
<?php
// Set the session value so that the user doesn't see this banner view again
$_SESSION['new_user'] = 'true';
}
?>
Posted: Sat Dec 24, 2005 11:12 pm
by Jenk
Posted: Sun Dec 25, 2005 12:19 am
by josh
looks like you forgot to call
session_start() at the top of your script...
and this line:
should be
especially since you're using equivalent to operator (===) instead of equal to (==)
Posted: Sun Dec 25, 2005 1:16 am
by jts_01
Sorry to post about this so much but now I getting
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/trance/public_html/flashtest.php:9) in /home/trance/public_html/flashtest.php on line 128
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/trance/public_html/flashtest.php:9) in /home/trance/public_html/flashtest.php on line 128
Code: Select all
<?php
session_start();
if ((isset($_SESSION['new_user'])) && ($_SESSION['visited'] === true)) {
// The user has seen the initial banner. Don't show it again.
?>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="510" height="205">
<param name="movie" value="flash/cougar1_re.swf">
<param name="quality" value="high">
<embed src="flash/cougar1_re.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="510" height="205"></embed>
</object>
<?php
} else {
?>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="510" height="205">
<param name="movie" value="flash/cougar1_.swf">
<param name="quality" value="high">
<embed src="flash/cougar1_.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="510" height="205"></embed>
</object>
<?php
// Set the session value so that the user doesn't see this banner view again
$_SESSION['new_user'] = true;
}
?>
Posted: Sun Dec 25, 2005 1:17 am
by jts_01
Sorry to post about this so much but now I getting
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/trance/public_html/flashtest.php:9) in /home/trance/public_html/flashtest.php on line 128
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/trance/public_html/flashtest.php:9) in /home/trance/public_html/flashtest.php on line 128
line 128 being session_start();
Code: Select all
<?php
session_start();
if ((isset($_SESSION['new_user'])) && ($_SESSION['visited'] === true)) {
// The user has seen the initial banner. Don't show it again.
?>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="510" height="205">
<param name="movie" value="flash/cougar1_re.swf">
<param name="quality" value="high">
<embed src="flash/cougar1_re.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="510" height="205"></embed>
</object>
<?php
} else {
?>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="510" height="205">
<param name="movie" value="flash/cougar1_.swf">
<param name="quality" value="high">
<embed src="flash/cougar1_.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="510" height="205"></embed>
</object>
<?php
// Set the session value so that the user doesn't see this banner view again
$_SESSION['new_user'] = true;
}
?>