Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Calling session (user)

Guest
Jan 31, 2013 Jan 31, 2013

Hi guys,

I want to display the user name in the dynamic textfield on the login success page (new page) but it keeps giving me 'undefined'. What's the problem?

login.php

<?php

session_start();

$username = $_POST['username'];

$password = $_POST['password'];

$_SESSION['username'] = $username;

. //other codes

.

.

?>

adminPage.php (successpage)

<?php

session_start();

$_SESSION['username'] = $_POST['username'];

$username = $_GET['username'];

    print "session=$username";

            ?>

AS3

import flash.display.*;

import flash.events.*;

import flash.net.URLLoader;

import flash.net.URLRequest;

import flash.net.URLVariables;

import flash.net.URLLoaderDataFormat;

import flash.net.URLRequestMethod;

var phpVarsSession:URLVariables = new URLVariables();

var phpFileRequestSession:URLRequest = new URLRequest("adminPage.php");

phpFileRequestSession.method = URLRequestMethod.POST;

var phpLoaderSession:URLLoader = new URLLoader();

phpLoaderSession.dataFormat = URLLoaderDataFormat.VARIABLES;

phpLoaderSession.addEventListener(Event.COMPLETE, showSession);

phpVarsSession.user = user.text;

phpFileRequestSession.data = phpVarsSession;

phpLoaderSession.load(phpFileRequestSession);

function showSession(event:Event):void

user.text = "" + event.target.data.session;

}

TOPICS
ActionScript
993
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jan 31, 2013 Jan 31, 2013

use:

adminPage.php (successpage)

<?php

session_start();

$_SESSION['username'] = $_POST['username'];

$username = $_POST['username'];

    print "session=$username";

            ?>

Translate
Community Expert ,
Jan 31, 2013 Jan 31, 2013

use:

adminPage.php (successpage)

<?php

session_start();

$_SESSION['username'] = $_POST['username'];

$username = $_POST['username'];

    print "session=$username";

            ?>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 31, 2013 Jan 31, 2013

Hey, thanks for replying.

I did use the code you gave me but it's still undefined though. Maybe the actionscript is the problem?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 01, 2013 Feb 01, 2013

copy and paste the trace output from:

AS3

import flash.display.*;

import flash.events.*;

import flash.net.URLLoader;

import flash.net.URLRequest;

import flash.net.URLVariables;

import flash.net.URLLoaderDataFormat;

import flash.net.URLRequestMethod;

var phpVarsSession:URLVariables = new URLVariables();

var phpFileRequestSession:URLRequest = new URLRequest("adminPage.php");

phpFileRequestSession.method = URLRequestMethod.POST;

var phpLoaderSession:URLLoader = new URLLoader();

phpLoaderSession.dataFormat = URLLoaderDataFormat.VARIABLES;

phpLoaderSession.addEventListener(Event.COMPLETE, showSession);

phpVarsSession.user = user.text;

trace("send",phpVarsSession.user);

phpFileRequestSession.data = phpVarsSession;

phpLoaderSession.load(phpFileRequestSession);

function showSession(event:Event):void

trace("received");

for(var s:String in event.target.data){

trace(s,event.target.data);

}

user.text = "" + event.target.data.session;

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 02, 2013 Feb 02, 2013

Nope. Didn't work. I've read from somewhere that the order of the session counts..I've tried it but it still doesn't work. But it's ok..it's not compulsory though, just trying to enhance my project. Haha.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 02, 2013 Feb 02, 2013

you didn't follow my suggestion.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 02, 2013 Feb 02, 2013

I did follow your suggestion but it's still undefined.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 02, 2013 Feb 02, 2013

this was the suggestion:  copy and paste the trace output from:

where's the trace output?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 02, 2013 Feb 02, 2013

Meaning i should edit my php too right? As it trace the send and received between the php and AS.. Sorry if i'm wrong, i don't really get what you mean.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 02, 2013 Feb 02, 2013

use the message 1 correction for your php.  that corrected an error in you php.

use the actionscript in message 3 which contains code to begin finding the cause of the problem.

if you're testing online and don't know how to check trace output from a browser, post the url to your embedding html page.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 02, 2013 Feb 02, 2013

Alrighty. I'll try that very soon. I'll report back to you if i run to any problems. Thanks so much for your time.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 02, 2013 Feb 02, 2013
LATEST

you're welcome.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines