xml output:
<balance>
<credits>39660</credits>
</balance>
how to fetch the xml output from url and store the credits i.e. 39660 into php variable.
the above xml output is coming from following url
http://www.xyz.com/check-balance.php?username=ssgent&password=ssgentr
check-balance.php code:
<?php
require('dbcon.php');
include('encrypt.php');
include('functions.php');
$username = $_GET['username'];
$password = $_GET['password'];
$password = encrypt($password, 'riffre');
$url = $_SERVER['HTTP_HOST'];
$url_length = strlen($url);
if (substr($url, 0, 4) == 'www.') {
$url_length = $url_length - 4;
$url = substr( $url, 4, $url_length );
}
$query = "select * from users where username='$username' and password='$password' and status='Active'";
if(!($result = mysql_query($query))) {
exit(mysql_error());
(bool)true;
}
$crq=mysql_fetch_array($result);
$userid = $crq['id'];
$rows = mysql_num_rows($result);
if ($rows != 1) {
echo 'Invalid Credentials.';
return 1;
}
else
{
$avail = check_user_credit($userid);
header('Content-Type: application/xml');
echo "<balance><credits>$avail</credits></balance>";
}
?>
hope some one will resolve this issue.
thanks in advance