Ok i am new to php and a few months into as3, i decided to test out php and as3, so i want to make a simple log on system with php, as3, and a few text file no MySQL or anything.
There are 3 text file set with some info in it like the user name, i want the user to type in a name that is set in the file already, and then a password, and the password is set as the new password for the account.
Everything works good except, i don't know how to tell the php which text file to look for, here is part of my code this part creates part of the account,
Here is my code:
AS3
ActionScript Code:
//create account with password
//create is a button that is pressed to set the password
create.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler2);
function fl_MouseClickHandler2(event:MouseEvent):void
{
function sendData():void {
variables = new URLVariables();
fData = new URLRequest("fSubmit2.php");
fData.method = URLRequestMethod.POST;
fData.data = variables;
fLoader = new URLLoader();
fLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
fLoader.addEventListener(Event.COMPLETE, sendComplete);
//alldata is the data that already exists in the text file
var myTextLoader:URLLoader = new URLLoader();
variables.TheText=alldata.text+'&mypasscode='+mypassword.text;
fLoader.load(fData);
}
function sendComplete(e:Event):void {
var loader:URLLoader = new URLLoader();
//username was typed in previously and the text file is the user name so i //type john as my name and there is a file named john.txt
loader.load(new URLRequest(username.text+".txt"));
}
sendData()
gotoAndStop(2);
}
}
Ok thats the as3, its only piece please say if i didnt explain something right thanks
Now ,here is my problem the php
PHP Code:
<?php
$getVar = $_POST[TheText];
$file = username+'.txt';
$writeVar = fopen($file,'w');
fwrite($writeVar,$getVar);
fclose($writeVar);
?>
It works perfectly except $file = username'.txt'; i can put
$file = 'john.txt'; but it would only access the john file i want it to access the file based on the name i type, please say if i am not clear, thanks in advance.