Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 09-04-2011, 12:05 AM   #1
Registered User
Join Date: Apr 2011
Posts: 7
Question Php and as3 variable help

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:
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:


$file username+'.txt';

$writeVar fopen($file,'w');



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.
johnreal is offline   Reply With Quote
Old 09-13-2011, 05:28 AM   #2
...not yet
notaflasher's Avatar
Join Date: Mar 2007
Posts: 90

John, there might be something else going on, but I'm curious about the "+" in the line you are having problems with.

Php doesn't recognize "+" as actionscript does. If you want to combine strings in php, use a dot.

$file = username.".txt";

And try substituting double quotes for singles unless you have sets of quotes nested inside another. I'm not saying that your single quotes are wrong, just that I have solved problems in the past by substituting one for the other when things weren't working as expected. I hope this helps.

And if henke37 shows up and gives you some grandiose explanation that makes him sound very intelligent, but doesn't help you in the slightest, join the crowd.
notaflasher is offline   Reply With Quote

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 Off
HTML code is Off

Forum Jump

All times are GMT. The time now is 01:56 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.