Created
September 6, 2009 14:17
-
-
Save johntdyer/181822 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
header("Content-type: text/xml"); | |
//My Auth PHP Script which will return some values | |
$phone = $_REQUEST['phone']; | |
$pin = $_REQUEST['pin']; | |
$host = "localhost"; | |
$user = "admin"; | |
$pass = "temppass"; | |
$db = "test"; | |
$tableName = "userData"; | |
$connection = mysql_connect($host, $user, $pass) | |
or die("Could not connect to host."); | |
$db_selected = mysql_select_db($db, $connection) | |
or die("Could not find database."); | |
$query=mysql_query("SELECT pin FROM " . $tableName . " WHERE phone = '$phone'"); | |
$query_row=mysql_fetch_array($query); | |
$userPin = $query_row['pin']; | |
if($userPin == $pin) | |
{ | |
//VALID USER | |
$userQuery=mysql_query("SELECT * FROM " . $tableName . " WHERE phone = '$phone'"); | |
$userSQLFetch=mysql_fetch_array($userQuery); | |
// XML START | |
$xml_output = "<?xml version=\"1.0\"?>"; | |
$xml_output .= "<" . $tableName . ">"; | |
$xml_output .= "<status>"; | |
$xml_output .= "<valid>"; | |
$xml_output .= "1"; | |
$xml_output .= "</valid>"; | |
$xml_output .= "</status>"; | |
$xml_output .= "<userInfo>\n"; | |
$xml_output .= "<ID>" . $userSQLFetch['id'] . "</ID>"; | |
$xml_output .= "<fName>" . $userSQLFetch['fName'] . "</fName>"; | |
$xml_output .= "<lName>" . $userSQLFetch['lName'] . "</lName>"; | |
$xml_output .= "<phone>" . $userSQLFetch['phone'] . "</phone>"; | |
$xml_output .= "<pin>" . $userSQLFetch['pin'] . "</pin>"; | |
$xml_output .= " " . "</userInfo>"; | |
$xml_output .= "</" . $tableName . ">"; | |
//XML END | |
echo $xml_output; | |
} else | |
{ | |
//INVALID USER | |
//XML START | |
$xml_output = "<?xml version=\"1.0\"?>"; | |
$xml_output .= "<" . $tableName . ">"; | |
$xml_output .= "<status>"; | |
$xml_output .= "<valid>"; | |
$xml_output .= "0"; | |
$xml_output .= "</valid>"; | |
$xml_output .= "</status>"; | |
$xml_output .= "</" . $tableName . ">"; | |
//XML END | |
echo $xml_output; | |
} | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<callxml version="3.0"> | |
<assign var="pin" expr="'1234'"/> | |
<assign var="phone" expr="'4074740000'"/> | |
<assign var="baseURL" expr="'http://localhost/peterg'"/> | |
<fetch value="$baseURL;/data.php" var="myFetch" submit="phone, pin" type="xml"/> | |
<block label="Axes" value="$myFetch;"> | |
<log> **** </log> | |
<log> $myFetch; </log> | |
<log> **** </log> | |
<wait value="1s"/> | |
<assign var="firstName" expr="/var/myFetch/userInfo/fName[1]/text()"/> | |
<assign var="lastName" expr="/var/myFetch/userInfo/lName[1]/text()"/> | |
<assign var="phone" expr="/var/myFetch/userInfo/phone[1]/text()"/> | |
<assign var="pin" expr="/var/myFetch/userInfo/pin[1]/text()"/> | |
<log>*** firstName: $firstName; ***</log> | |
<log>*** lastName: $lastName; ***</log> | |
<log>*** Phone: $phone; ***</log> | |
<log>*** PIN: $pin; ***</log> | |
<say> User name is $firstName; $lastName; </say> | |
<say> Phone number </say><playnumber format="digits" value="$phone;"/> | |
<say> Pin is $pin; </say> | |
</block> | |
</callxml> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ID fName lName phone pin | |
-------------------------------------------- | |
1 John Dyer 4074740000 1234 | |
2 Stan Smith 4075551212 5555 | |
3 Homer Simpson 4078230004 4444 | |
4 Billy Bob 4074343434 5543 | |
5 Joe Dirt 4073434343 4343 | |
6 Sasha Dog 4074747021 1111 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment