2011-11-05 6 views
1

웹 사이트 로그인 인터페이스 용으로 php 및 as3 코드를 만들었습니다. 나는 status1.text로 바로 e.target.data.systemResult를 얻을 수 있지만, 지금PHP -> AS3 if 문

function dataOnLoad(e: Event) //after pressing submit button 
{ 
    status1.selectable = false; 
    status1.text = e.target.data.systemResult 
    status1.autoSize = TextFieldAutoSize.LEFT; 
    if (e.target.data.systemResult == "joe") { 
     MovieClip(root).gotoAndStop(3); 
    } else { 
     status2.text = "Doesn't work"; 
    } 
} 

, 나는 올바른 사용자 이름과 암호를 사용하여 제출 '버튼을 누를 때마다 다음은

<?php 

    $con = mysql_connect("xxx", "xxx", "xxx"); 
    mysql_query($con); 
    if (!$con) { 
     die('Could not connect: ' . mysql_error()); 
    } 
    mysql_select_db("xxx", $con) or die('no02'); 
    $username = $_POST['username']; 
    $pass = md5($_POST['pass']); 
    if ($_POST['systemCall'] == "checkLogin") { 
     $select = "SELECT username FROM connexion WHERE username='$username' AND pass='$pass'"; 
     $query = mysql_query($select); 

     $counter = 1; 
     while ($row = mysql_fetch_array($query)) { 
      $name = $row['username']; 
      if ($name == "joe") { 
       print "systemResult=joe"; 
      } 
      $counter = $counter + 1; 
     } 
    } 

    mysql_close($con); 

?> 

AS3 코드 있어요 다음은 PHP 코드입니다 if 문이 e.target.data.systemResultjoe 사이의 동등 함을 인식하지 못하는 이유를 알 수 없습니다. 항상 status2.text에 "작동하지 않음"이라고 씁니다.

+2

공백이'>'후이없는 있는지 확인합니다. '?>'는 제거 할 수 있으며 선택 사항입니다. – Kapep

+1

먼저 * SQL injection *에 대해 읽어야합니다. –

+0

"Joe"또는 "Joe"가 아닌지 확인하십시오. –

답변

2

나는 잠시 후에 as3에서 놀지는 않았지만 문제에 대한 설명에 따라 systemResult가 엄격한 비교가 일치하지 않을 수도있는 객체 유형이라고 추측합니다. systemResult에 적용 할 수있는 toString() 메서드가있어 비교 결과가 변경되는지 확인합니다.

function dataLoaded(e:Event) 
{ 
    var phpvars:URLVariables = new URLVariables(e.target.data); 

    if (phpvars.systemResult == "joe") 
    { 
     status2.text = "Works!"; 
    } 
} 

을하고 PHP 로더 DATAFORMAT을 설정 :

0

봅니다 URLVariables를 사용 하는가?

phploader.dataFormat = URLLoaderDataFormat.VARIABLES; 
+0

나는 그런 식으로 이미 시도했지만 효과가 없었습니다. –

+0

phpvars와 phpvars.systemResult를 추적하여 그 결과가 무엇인지 살펴볼 수 있습니다. –