Guest User

Untitled

a guest
Mar 12th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. <?
  2. header("Content-type: text/xml");
  3.  
  4. //My Auth PHP Script which will return some values
  5.  
  6. $phone = $_REQUEST['phone'];
  7. $pin = $_REQUEST['pin'];
  8.  
  9. $host = "localhost";
  10. $user = "admin";
  11. $pass = "temppass";
  12. $db = "test";
  13. $tableName = "userData";
  14.  
  15. $connection = mysql_connect($host, $user, $pass)
  16. or die("Could not connect to host.");
  17.  
  18. $db_selected = mysql_select_db($db, $connection)
  19. or die("Could not find database.");
  20.  
  21. $query=mysql_query("SELECT pin FROM " . $tableName . " WHERE phone = '$phone'");
  22. $query_row=mysql_fetch_array($query);
  23.  
  24. $userPin = $query_row['pin'];
  25.  
  26. if($userPin == $pin)
  27. {
  28.  
  29. //VALID USER
  30. $userQuery=mysql_query("SELECT * FROM " . $tableName . " WHERE phone = '$phone'");
  31. $userSQLFetch=mysql_fetch_array($userQuery);
  32.  
  33. // XML START
  34. $xml_output = "<?xml version=\"1.0\"?>";
  35. $xml_output .= "<" . $tableName . ">";
  36.  
  37. $xml_output .= "<status>";
  38. $xml_output .= "<valid>";
  39. $xml_output .= "1";
  40. $xml_output .= "</valid>";
  41. $xml_output .= "</status>";
  42.  
  43. $xml_output .= "<userInfo>\n";
  44. $xml_output .= "<ID>" . $userSQLFetch['id'] . "</ID>";
  45. $xml_output .= "<fName>" . $userSQLFetch['fName'] . "</fName>";
  46. $xml_output .= "<lName>" . $userSQLFetch['lName'] . "</lName>";
  47. $xml_output .= "<phone>" . $userSQLFetch['phone'] . "</phone>";
  48. $xml_output .= "<pin>" . $userSQLFetch['pin'] . "</pin>";
  49. $xml_output .= " " . "</userInfo>";
  50. $xml_output .= "</" . $tableName . ">";
  51. //XML END
  52.  
  53. echo $xml_output;
  54. } else
  55. {
  56. //INVALID USER
  57.  
  58. //XML START
  59. $xml_output = "<?xml version=\"1.0\"?>";
  60. $xml_output .= "<" . $tableName . ">";
  61. $xml_output .= "<status>";
  62. $xml_output .= "<valid>";
  63. $xml_output .= "0";
  64. $xml_output .= "</valid>";
  65. $xml_output .= "</status>";
  66. $xml_output .= "</" . $tableName . ">";
  67. //XML END
  68. echo $xml_output;
  69. }
  70. ?>
Add Comment
Please, Sign In to add comment