Copy link to clipboard
Copied
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;
}
use:
adminPage.php (successpage)
<?php
session_start();
$_SESSION['username'] = $_POST['username'];
$username = $_POST['username'];
print "session=$username";
?>
Copy link to clipboard
Copied
use:
adminPage.php (successpage)
<?php
session_start();
$_SESSION['username'] = $_POST['username'];
$username = $_POST['username'];
print "session=$username";
?>
Copy link to clipboard
Copied
Hey, thanks for replying.
I did use the code you gave me but it's still undefined though. Maybe the actionscript is the problem?
Copy link to clipboard
Copied
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;
}
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
you didn't follow my suggestion.
Copy link to clipboard
Copied
I did follow your suggestion but it's still undefined.
Copy link to clipboard
Copied
this was the suggestion: copy and paste the trace output from:
where's the trace output?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
you're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now