Forum Moderators: coopster
I was going to use javascript to do this but I was told on the javascript forum that it would be far easier using a server-side language like php.
Is it possible to pass a global variable from an intro page?
Currently, I have a flash intro and the option to 'Skip Intro' on the intro page.
I'd also like an option on the intro page to 'Skip intro and turn the music off' on all pages on the site.
That way my dial-up users can enjoy the site without the wait.
My current code works fine in IE 6 and my next project is to get it to work in FireFox (input on this would be great too!)
Currently my music code for each page is very simply:
<script language="JavaScript">
var NFsong = "http://example.com/mm5/music/m3u/storefront.m3u" [the *.m3u references an mp3 file and is different on each page of the site]
</script>
And the global footer has the player code:
<script language="javascript">
<!--
document.write("PAUSE <embed src=\""+NFsong+"\" style=\"width:44px;height:26px\" loop=\"true\" > MUSIC");
//-->
</script>
<BR>
Any help on passing a global variable from the intro page would be GREATLY appreciated!
Thanks in advance!
Joe
[edited by: coopster at 4:16 pm (utc) on May 8, 2006]
[edit reason] removed urls per TOS [webmasterworld.com] [/edit]
you could do something like this:
footer.php
if($_GET[music] == 1)
{
echo "<script language='javascript'>
document.write(\"PAUSE <embed src=\"'+NFsong+'\" style='width:44px;height:26px' loop='true' > MUSIC\");
</script> ";
echo "<a href='$_SERVER[PHP_SELF]?music=0'>Stop music</a>";else {
echo "<a href='$_SERVER[PHP_SELF]?music=1'>Play music</a>";
}
Now whenever you want to include this music you just type include(footer.php); and it will be added with the appropriate links. Of course now you will have to remove the script that adds the <embed> in your files, and replace everything with what i have.
Good luck!
eelix
I'm brand new to php, so my first assumption is that the code in the box should be saved within a text editor to a file called footer.php. And I should be this file in the same folder on the server as my *.html is in.
If I am correct in these assumptions, then I must be screwing the 'include(footer.php);' line up because nothing is appearing on my *.html page. I've tried it many different ways and tried googling for the proper convention but I haven't had any luck yet.
I believe it to be something like this..
<?php include("footer.php");?>
What is the exact call/include line? And if this is correct, are there any other reasons why the code isn't working?
Thanks again!
Joe
would work as long as footer.php was located in the same directory as the file including it
otherwise you could put footer.php in the root directory of your site ad use this from any file within your site structure
<?php include $SERVER['DOCUMENT_ROOT'] . '/footer.php';?>
Revised footer.php
f($_GET[music] == 1)
{
echo "<script language='javascript'>
document.write(\"PAUSE <embed src=\"'+NFsong+'\" style='width:44px;height:26px' loop='true' > MUSIC\");
</script> ";
echo "<a href='$_SERVER[PHP_SELF]?music=0'>Stop music</a>";
}
else {
echo "<a href='$_SERVER[PHP_SELF]?music=1'>Play music</a>";
}
The above code should work properly now.
eelix
I don't get any error messages. It simply doesn't do anything.
I have no idea whether it is the include or the code which is causing the problem.
Is there a very simple piece of code which I can 'include' to test whether the issue is with the code or the include?
Thanks for your help so far guys!
Joe
This will show all errors and warnings in your script
eelix
I added the code to my footer.php file but where are the errors supposed to show themselves? The html file? It still isn't showing anything.
Another recap, to make sure I'm not missing anything:
1) The piece of code that you gave me should be saved in a file called 'footer.php'.
2) My *.html file should have an include file that says EXACTLY this:
<?php include("footer.php");?>
3) Both files should be in the same folder on my server.
If all of this is correct, this is what I've already done. I've also tried putting the php file in my root and using the include line suggested by jatar_k - <?php include $SERVER['DOCUMENT_ROOT'] . '/footer.php';?>
It seems like this should be simple but I'm at a loss. Is there anything else that I could be missing? I've NEVER used php before so don't assume that I know even the basic conventions or procedures. Can you think of anything else that I may be leaving out or don't wrong?
maybe you can't use php in html files
I don't think you can. Try changing all your files with the include() in it to *.php in order for the php to work correctly.
eelix