John_A Posted December 18, 2006 Share Posted December 18, 2006 I need to have a PHP variable for flash installed (e.g. $hasFlashSupport='true'), I know I can't actually use PHP for the flash detection, but I've used [url=http://blog.deconcept.com/swfobject]swfobject[/url] before for this (the flash detection) without any problems.What I need to know how to do is take the flash / noflash variable from swfobject and put this as a session variable in PHP. Unfortunately the only thing I know less of than PHP is Javascript :(I can't actually use swfobject to display the flash / noflash content, as swfobject assumes you want to actually display a flash movie if it's found, when I actually want to show alternative content (i.e. a link to a flash microsite), for example: -[code] if ($hasFlashSupport=='true') { //visitor has flash installed echo "<a href='flashpages.php'>Flash content</a>"; } else { //visitor doesnt have flash installed echo "<a href='noflash.php'>HTML content</a>"; }[/code]I've tried this: -[code] //check for flash and set variable accordingly if(eregi("application/x-shockwave-flash", $_SERVER['HTTP_ACCEPT'])) { //viewer has flash $hasFlashSupport=true; } else { //viewer doesnt have flash $hasFlashSupport=false; }[/code]but that's proven to be rather unreliable :( Quote Link to comment Share on other sites More sharing options...
Cep Posted December 18, 2006 Share Posted December 18, 2006 Easiest way I have found is to create a hidden input like,<input name='myFlash' type='hidden' value='' />then I would change your Javascript to set the value of above input to that of the flashsupport = true part dependant on what triggers that, and then IF (and here is the big presumption on my part that your using a form) you submit this to your PHP script you can use $_POST to collect the variable value and do what you like with it. Quote Link to comment Share on other sites More sharing options...
John_A Posted December 20, 2006 Author Share Posted December 20, 2006 Thanks, but I'm not using a form, I want to add this into the header of every page, although the check is only done if the session variable for flash support hasn't been set yet, kind of like: -If (php session variable $hasFlashSupport isn't set) { detect flash with swfobject write php session variable }I think this may be as much a Javascript issue as php, so if the mods don't mind I'll double post in that forum.... Quote Link to comment Share on other sites More sharing options...
John_A Posted December 20, 2006 Author Share Posted December 20, 2006 I just had a thought, what if I do the normal swfobject to detect flash, which if found displays a flash movie which writes the php variable?This assumes you can write a php session variable using flash. Can you? Quote Link to comment Share on other sites More sharing options...
Cep Posted December 21, 2006 Share Posted December 21, 2006 You can't detect a session from PHP with Javascript to my knowledge. You could pass a variable value from PHP to an HTML element (outputted from php) which you could then use Javascript to read, similar to what I mentioned above but in the opposite direction.I have never heard of being able to write php variables with flash no and if your not using a form you will not be able to change the PHP session variable without using something like AJAX as you need to send the value from your client side back to the server at some point. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.