473,396 Members | 2,039 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Actionscript 3 with PHP

I am trying to create an authentication using flash and AS3 as the underlying code using PHP as the server side scripting and mySQL to store the passwords. As I am a newbie I decided to start practicing using AS2 and tried to make the whole thing work. I could not get the flash interface to connect to the PHP to validate the database. I know that my PHP code worked because I can run a test through the browser and it would connect to the mySQL database. I decided then to opt to convert it to AS3. I could not get it to work is AS3 neither. Doing so changed the code so that I would have the PHP code holding the username and password as a test but I could not get this to work. It seems to me that my flash interface isnt connecting to the php script.

Here are my codes....any help would be great....I also enclose the error message I am now receiving which I do not understand why.


Expand|Select|Wrap|Line Numbers
  1. mcLogin.addEventListener(MouseEvent.CLICK, onClick);
  2.  
  3. function onClick(event:MouseEvent):void
  4. {
  5.     var variables = new URLVariables();
  6.     variables.username = tUsername.text;
  7.     variables.password = tPassword.text;
  8.  
  9.     var _request:URLRequest = new URLRequest("loginCheck.php");
  10.     _request.data = variables;
  11.     _request.method = URLRequestMethod.POST;
  12.  
  13.     var _loader:URLLoader = new URLLoader()
  14.     _loader.dataFormat = URLLoaderDataFormat.VARIABLES;
  15.     _loader.addEventListener(Event.COMPLETE, sendComplete);
  16.     _loader.addEventListener(IOErrorEvent.IO_ERROR, sendIOError);
  17.     _loader.load(_request);
  18. }
  19.  
  20. function sendComplete(event:Event):void
  21. {
  22.      tError2.text = "I'm sorry, it didnt load";
  23. }
  24.  
  25. function sendIOError(event:IOErrorEvent):void
  26. {
  27.     tError.text = "I'm sorry, it didnt load";
  28. }
[PHP]<?php
session_start();
$username = $_POST['username'];
$password = $_POST['password'];


if($username == 'admin' && $password == 'admin123'){
$_SESSION['loggedIn'] = true;
echo 'login=success';
}else{
echo 'login=failure';
}
?> [/PHP]


Error: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs.
at Error$/throwError()

I dont have any ampersand so I dont know why this is thrown..

Any help would be great..

Thanks
Dec 28 '07 #1
4 16907
Try to change the path to php file to the full url like http://www.[domain].com/file.php
Jul 14 '08 #2
I am having the same problem. Did you ever figure out a solution? I've been banging my head all week getting this to work. It seems as though the php script I have is not being executed. In my Event.COMPLETE event handler I can inspect the event.target.data and what I get back is the entire php script! Please help!
Jun 10 '09 #3
gopan
41
@porksoda
Are you sure that your server executes php scripts??
Try the url to php file in a browser...
Aug 13 '09 #4
Whenever you make a PHP API for something, you should always craft manual requests and ensure the script itself is responding as expected. My guess is that your problem comes from server side. Do a few trace() calls and check the contents of the page you receive. If that doesn't help you, then get friendly with telnet or one of those fancy request crafting addons for FFox.
Aug 17 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Matt | last post by:
Hello, I am attempting to get a software prototype UI/demo built in Flash to talk with existing C++ (so I can exchange data and commands between the application-software already developed in the...
1
by: karin nguyen | last post by:
Hi, i am a new user for flash / actionscript. Now our lecturer asked us to do research for actionscript together with the flash file as example but I only can find the actionscript without flash...
1
by: itsthefocusman | last post by:
Hi everyone my name is Daniel, I would like some help. I am using Flash 8 to build a website. I have built the whole site within one flash movie by building the different sections of the site...
1
by: Adam Chapman | last post by:
Hello, I am trying to make an application with a flash interface which does calcultaions in the more powerful c++. Basically I want to be able to draw a shape in flash and do some structural...
1
by: Rocky86 | last post by:
hi ppl bascially I am require to pass my php coding to actionscript and the actionscript will seperate the code of my php how do I do it? Must I create a function for php to be pass into actionscript...
3
by: JuneNasch | last post by:
Hi. I'm a beginner in using Actionscript. Do you know what is the actionscript for a button to exit or quit my project? I'm using Flash 8 pro. I don't know which version of actionscript is used,...
0
by: gabrielk43 | last post by:
Hi I am new to Flex and I use Flex Builder 2 to make a web service client. So I have a web service in .NET(c#) with a simple web method that returns a string(no arguments). It works, I tested it...
2
by: mfsiddiq | last post by:
HI I am facing some problem with my as-js communication.I am passing a String expression to a javascript function using ExternalInterface.call function upon mouse click.My string expression is as...
1
by: cyra | last post by:
Hi guys, this is the first time I post in our forum, I would like to say thanks to whom reading this. I'm new to ASv3 and in stuck of dealing with a problem like this : I have some .fla file...
4
nathj
by: nathj | last post by:
Hi, Well the title of the thread is the question. I have tried searching for this and after several days of getting nowhere with it I decided I would ask. So here's the deal. I am using Flash...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.