shizny
03-04-2004, 08:21 PM
I have a flash xml object that I would like to send to php and have php write the object to a xml file. Does anybody know how to do that in php?
zzcamarinha
03-27-2004, 02:50 PM
maybe this code can help you:
<?
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// This script takes xml from xml_sal_php.fla, check the content then sends an xml document back with the results.
// You need to change the function startElement() and the line in the if statement that echoes the username
// - it's hardcoded and you need to adapt it to your setup. The version in comments connects to a MySQL database
// and uses crypt to test the password - this isn't secure cos you just transmitted the details in plain text
// over http - use SSL if you need more.
//
// Contact j.b@dynamitechicken.com wih queries.
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$my_xml = $GLOBALS["HTTP_RAW_POST_DATA"];
$login = 0;
$user = "";
$email = "";
/*function startElement($parser, $name, $attrs) {
global $login, $user, $email;
if (strtolower($name)=="user") {
$connection = mysql_connect('localhost', 'jaybee', 'seaside99');
mysql_select_db('jaybee',$connection);
$sql = "SELECT * FROM users WHERE user_password = '".crypt($attrs["PASSWORD"],$attrs["NAME"])."'";
$qry_login = mysql_query($sql,$connection);
if ($row = mysql_fetch_array($qry_login)) {
$login = true;
$user = $row["user_name"];
$email = $row["user_email"];
}
}
}*/
function startElement($parser, $name, $attrs) {
global $login;
if (strtolower($name)=="user") {
if ($attrs["NAME"] == "titus" && $attrs["PASSWORD"] == "groan") {
$login = true;
}
}
}
function endElement($parser, $name) {
}
// initialize parser
$xml_parser = h();
// set callback functions
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_parse($xml_parser, $my_xml);
// clean up
xml_parser_free($xml_parser);
if (!$login) {
echo "<no_login />";
} else {
echo "<results success=\"yes\" name=\"titus\" email=\"j.b@dynamitechicken.com\" />";
//echo "<results success=\"yes\" name=\"$user\" email=\"$email\" />";
}
?>
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.