i'm still novice in AS3 Programming i was trying to get a login screen to work on my AIR Application, but i got error #2101 The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs.
here's the code for processLogin
public function processLogin():void {
if(username.text != "" && password.text != "")
{
var checkName = username.text
var checkPass = password.text
var resulttext = result_text.text
var request:URLRequest = new URLRequest("http://localhost/caservers/aksessistemlogin.php")
var loader:URLLoader = new URLLoader()
var variables:URLVariables = new URLVariables()
variables.username = checkName
variables.password = checkPass
variables.systemResult = resulttext
loader.dataFormat = URLLoaderDataFormat.VARIABLES
request.data = variables
request.method = URLRequestMethod.POST
loader.addEventListener(Event.COMPLETE, logincheck)
loader.load(request)
}
function logincheck (event:Event):void {
if (username.text == checkName && password.text == checkPass){
gotoAndPlay(2);
}else{
result_text.text = resulttext ;
}
}
}
and this one is the code for PHP
<?php
include_once "connect.php";
$username = $_POST['username'];
$password = $_POST['password'];
if ($_POST['systemCall'] == "checkLogin") {
$sql = "SELECT * FROM users WHERE username='$username' AND password='$password'";
$query = mysqli_query($sql);
$login_counter = mysqli_num_rows($query);
if ($login_counter > 0) {
while ($data = mysqli_fetch_array($query)) {
}
} else {
$systemResult = "The login details don't match our records";
}
}
?>
what i'm intend to do is to check if the username and password is match with the one in the database, i followed some tutorials but it ended up advancing to next frame even without typing anything in the text input (just by clicking submit).
any help will be very very appreciated! thanks in advance..
loader.dataFormat = URLLoaderDataFormat.VARIABLES- BadFeelingAboutThis