Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 06-19-2012, 11:34 AM   #11
-:)lauri
Senior Member
 
Join Date: Aug 2008
Location: Helsinki, Finland
Posts: 1,184
Default

Try with orginal function:

PHP Code:
function logout1(){
    global 
$logoutAction2;
    
$logoutAction2 $_SERVER['PHP_SELF']."?doLogout=true";
    if ((isset(
$_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
        
$logoutAction2 .="&"htmlentities($_SERVER['QUERY_STRING']);
    }
    
    if ((isset(
$_GET['doLogout'])) &&($_GET['doLogout']=="true")){
        
//to fully log out a visitor we need to clear the session varialbles
        
$_SESSION['MM_Username'] = NULL;
        
$_SESSION['MM_UserGroup'] = NULL;
        
$_SESSION['PrevUrl'] = NULL;
        unset(
$_SESSION['MM_Username']);
        unset(
$_SESSION['MM_UserGroup']);
        unset(
$_SESSION['PrevUrl']);
        
$logoutGoTo "../../login.php";
        if (
$logoutGoTo) {
            
header("Location: $logoutGoTo");
            exit;
        }
    }

...as you can see there is a "header()" and not "return".

Well and there is "exit" too which means you probably should add it in this also:

PHP Code:
<?php 
    
if(isset($_POST['logout']))  
    { 
        
header("Location: ".$logoutAction2);
    } 
?>
to get

PHP Code:
<?php 
    
if(isset($_POST['logout']))  
    { 
        
header("Location: ".$logoutAction2);
        exit;
    } 
?>
just every time you're using the header().
-:)lauri is offline   Reply With Quote
Old 06-19-2012, 03:23 PM   #12
mydogmax
Registered User
 
Join Date: Jun 2008
Posts: 42
Default

Hi

My logout button is now working as required.
Many thanks for your help.

If possible could you add a couple of comments to the following code
just so that I have a better idea what is going on.
Code:
{
    post.logout = "laksfslvs";
    var ureq:URLRequest = new URLRequest(fileName);
    ureq.data = post;
    ureq.method = URLRequestMethod.POST;
    navigateToURL( ureq, "_self");
}
Best regards Maxwell
mydogmax is offline   Reply With Quote
Old 06-19-2012, 06:30 PM   #13
mydogmax
Registered User
 
Join Date: Jun 2008
Posts: 42
Default

My plan is to add the logout button to multiple files. So I would change this line to

var fileName:String = "../../public/computers/computers.php";

I noticed when I added the same button as previous to a file in the same folder as computers_publicaccess.php called computers.php
the button still worked.

This makes me think that the following line may not be needed

var fileName:String = "../../public/computers/computers_publicaccess.php";

Code:
import flash.events.MouseEvent;
import flash.net.URLLoader;


var fileName:String = "../../public/computers/computers_publicaccess.php";

var post:URLVariables = new URLVariables();
logOutBtn.addEventListener(MouseEvent.CLICK, onClick);

function onClick(event:MouseEvent):void
{
    post.logout = "laksfslvs";
    var ureq:URLRequest = new URLRequest(fileName);
    ureq.data = post;
    ureq.method = URLRequestMethod.POST;
    navigateToURL( ureq, "_self");
}
mydogmax is offline   Reply With Quote
Old 06-19-2012, 10:07 PM   #14
-:)lauri
Senior Member
 
Join Date: Aug 2008
Location: Helsinki, Finland
Posts: 1,184
Default

ActionScript Code:
{     // First we define variable "logout" and give it some value, so     // it is correctly defined and php can detect that. post is an     // object of URLVariables     post.logout = "laksfslvs";     // Then we define url request object that takes the url as a     // string     var ureq:URLRequest = new URLRequest(fileName);     // We add our URLVariables to our url request object     ureq.data = post;     // Then we define the method type that will be used to     // transferring data to server and we use POST     ureq.method = URLRequestMethod.POST;     // Finally we just launch a www site with our url request     // object. "_self" is optional html tag and while I'm not sure     // could user force the page open in some other window     // at least this shouldn't open new window and just     // refreshes the currentone.     navigateToURL( ureq, "_self"); }
-:)lauri is offline   Reply With Quote
Old 06-19-2012, 11:03 PM   #15
-:)lauri
Senior Member
 
Join Date: Aug 2008
Location: Helsinki, Finland
Posts: 1,184
Default

I'm pretty sure you need url address to post any values to any server from swf object. But then if you have your swf object inside of the <a></a> tags as was your previous button then you wouldn't probably need a single line of any code in your Flash. But I haven't been testing that so much so there may be some other ways to do the job that I'm not aware of.

* * *

Anyway if you need to reuse your button, maybe you should give the address to the flash dynamically via flashvars, which you can define at the same time you define the swf object on your html page, which should look with older implementations something like this:

Code:
<?php $address = "../../public/computers/computers_publicaccess.php"; ?>
<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="400" title="ReadingFlashVars">
	<param name="movie" value="ReadingFlashVars.swf" />
	<param name="quality" value="high" />
	<param name="FlashVars" value="url=<?php echo $address; ?>" />
	<embed src="ReadingFlashVars.swf" width="550" height="400" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" FlashVars="url=<?php echo $address; ?>"></embed>
</object>
Then in the actionscript file something like this may work:

ActionScript Code:
import flash.events.MouseEvent; import flash.net.URLLoader; var fileName:String = LoaderInfo(this.root.loaderInfo).parameters.url; var post:URLVariables = new URLVariables(); logOutBtn.addEventListener(MouseEvent.CLICK, onClick); function onClick(event:MouseEvent):void {     post.logout = "laksfslvs";     var ureq:URLRequest = new URLRequest(fileName);     ureq.data = post;     ureq.method = URLRequestMethod.POST;     navigateToURL( ureq, "_self"); }
-:)lauri is offline   Reply With Quote
Old 06-20-2012, 12:20 AM   #16
mydogmax
Registered User
 
Join Date: Jun 2008
Posts: 42
Default

Many thanks for all of your help!

Regards Maxwell
mydogmax is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:44 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.