从 httpservics 获取未处理的 php 作为结果 FB4
您好,请帮忙,我在 flash builder 4 中使用 httpservice 作为登录系统,但我从服务器得到的结果是原始 php 未处理的数据,但是当我在浏览器中运行相同的文件时,我得到了一个正确的 xml 文件,我使用 MAMP, 请帮忙,不知道这里有什么问题是 php 代码:
<?php
define( "DATABASE_SERVER", "localhost:8888" );
define( "DATABASE_USERNAME", "root" );
define( "DATABASE_PASSWORD", "root" );
define( "DATABASE_NAME", "touch" );
//connect to the database
$mysql = mysql_connect(DATABASE_SERVER, DATABASE_USERNAME, DATABASE_PASSWORD) or die(mysql_error());
//select the database
mysql_select_db( DATABASE_NAME );
//These are the variables that Flex is passing to PHP
$username = mysql_real_escape_string($_POST["username"]);
$password = mysql_real_escape_string($_POST["password"]);
$logincookie = mysql_real_escape_string($_POST["logincookie"]);
//Check the credentials
$query = "SELECT * FROM users WHERE username = '$username' AND password = '$password'";
$result = mysql_fetch_array(mysql_query($query));
//Output the returned query in XML: If returned false output 0 else output the users id
$output = "<?xml version='1.0' encoding='utf-8'?>";
$output .= "<loginsuccess>";
if(!$result)
{
$output .= $username;
}else{
$output .= $username;
}
$output .= "</loginsuccess>";
//Output the User Type
$usrtyp .= "<usertype>";
$usrtyp .= $result['user_type'];
$usrtyp .= "</usertype>";
//output all the XML
print ($output);
print ($usrtyp);
?>
这是请求:
<s:HTTPService id="login_user" result="checkLogin(event)" showBusyCursor="true" method="POST"
url="login.php" useProxy="false">
<s:request xmlns="">
<username>
{username.text}
</username>
<password>
{password.text}
</password>
</s:request>
</s:HTTPService>
Hello pleassse help am using httpservice in flash builder 4 for a login system, but am getting the result as raw php unprocessed data from server, but when i run the same file in the browser i get a correct xml file am using MAMP,
PLEASE HELP donno what's the problem here is the php code :
<?php
define( "DATABASE_SERVER", "localhost:8888" );
define( "DATABASE_USERNAME", "root" );
define( "DATABASE_PASSWORD", "root" );
define( "DATABASE_NAME", "touch" );
//connect to the database
$mysql = mysql_connect(DATABASE_SERVER, DATABASE_USERNAME, DATABASE_PASSWORD) or die(mysql_error());
//select the database
mysql_select_db( DATABASE_NAME );
//These are the variables that Flex is passing to PHP
$username = mysql_real_escape_string($_POST["username"]);
$password = mysql_real_escape_string($_POST["password"]);
$logincookie = mysql_real_escape_string($_POST["logincookie"]);
//Check the credentials
$query = "SELECT * FROM users WHERE username = '$username' AND password = '$password'";
$result = mysql_fetch_array(mysql_query($query));
//Output the returned query in XML: If returned false output 0 else output the users id
$output = "<?xml version='1.0' encoding='utf-8'?>";
$output .= "<loginsuccess>";
if(!$result)
{
$output .= $username;
}else{
$output .= $username;
}
$output .= "</loginsuccess>";
//Output the User Type
$usrtyp .= "<usertype>";
$usrtyp .= $result['user_type'];
$usrtyp .= "</usertype>";
//output all the XML
print ($output);
print ($usrtyp);
?>
and here is the request :
<s:HTTPService id="login_user" result="checkLogin(event)" showBusyCursor="true" method="POST"
url="login.php" useProxy="false">
<s:request xmlns="">
<username>
{username.text}
</username>
<password>
{password.text}
</password>
</s:request>
</s:HTTPService>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我大胆猜测您不是在 HTTP 服务器上运行它,而只是引用文件系统上的 html/swf 文件本身,因此 PHP 没有被处理。
I'm going with a wild guess that you're not running this off of an HTTP server, but just referencing to the html/swf file itself on your filesystem, hence the PHP is not being processed.