Guest User

Untitled

a guest
Dec 10th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. <?
  2. include 'validateschema.php';
  3. //echo $_SESSION['validate'];
  4. if(!validate())
  5. {
  6. echo "There was an error in the XML Validation";
  7. }
  8. else
  9. {
  10.  
  11. //GET USER
  12. foreach($xml->user as $users) {
  13. echo "{$users->firstname} - {$users->lastname} - {$users->username} - {$users->password} - {$users->email} - {$users->sellamount} - {$users->buyamount} - {$users->level}\t\n";
  14.  
  15. $first= $users->firstname;
  16. $last=$users->lastname;
  17. $user=$users->username;
  18. $pass=$users->password;
  19. $mail=$users->email;
  20. $sell=$users->sellamount;
  21. $buy=$users->buyamount;
  22. $level=$users->level;
  23. //echo "<br>".$first." ".$last." ".$user." ".$pass." ".$mail." ".$buy." ".$sell." ".$level."<br>";
  24. //ADD INTO TBLMEMBERS
  25. $query="INSERT INTO tblMembers VALUES('', '$first', '$last', '$user', '$pass', '$mail', $sell, $buy, $level)";
  26. $result=mysql_query($query) or die("Member was not inserted into tblmembers");
  27.  
  28. //ADD Idmember to XML IDMember
  29. $query="SELECT LAST_INSERT_ID() from tblMembers";
  30. $result= mysql_query($query);
  31. $row=mysql_fetch_array($result);
  32. $insertedID=$row['LAST_INSERT_ID()'];
  33.  
  34. $xml->user->idmember = "$insertedID";
  35. file_put_contents('cellphone.xml', $xml->asXML());
  36. if(!validate())
  37. {
  38. echo "There was an error in the data inputed";
  39. }
  40. }
  41.  
  42. //GET PHONE
  43. foreach($xml->phone as $phones) {
  44. echo "{$phones->model} - {$phones->brand} - {$phones->Sellprice} - {$phones->color} - {$phones->SellDate} - {$phones->Features} - {$phones->condition} - {$phones->Cellstatus}\t\n";
  45.  
  46. $model= $phones->model;
  47. $brand=$phones->brand;
  48. $sellp=$phones->Sellprice;
  49. $color=$phones->color;
  50. $selld=$phones->SellDate;
  51. $features=$phones->Features;
  52. $condition=$phones->condition;
  53. $cellstatus=$phones->Cellstatus;
  54. $buyp=$phones->buyprice;
  55. $buyd=$phones->buydate;
  56. $idmem=$phones->idmember;
  57. $image=$phones->image;
  58. $views=$phones->views;
  59.  
  60. //ADD PHONE TO DB
  61. $query="INSERT INTO tblSellphones VALUES('','$image', '$model', '$brand', '$sellp', '$color', '$selld', '$features', '$condition', '$idmem', '$cellstatus', '$views', '$buyp', '$buyd')";
  62. $result=mysql_query($query) or die("Phone was not inserted into tblsellphones");
  63.  
  64.  
  65. $query="SELECT LAST_INSERT_ID() from tblSellphones";
  66. $result= mysql_query($query);
  67. $row=mysql_fetch_array($result);
  68. $insertedID=$row['LAST_INSERT_ID()'];
  69.  
  70. $phones->idcellphone = "$insertedID";
  71. file_put_contents('cellphone.xml', $xml->asXML());
  72. if(!validate())
  73. {
  74. echo "There was an error in the data inputed";
  75. }
  76. }
  77.  
  78. echo "<a href='dispphone.php'>You can now purchase a phone of your choice</a>";
  79. }
  80. //MAKE USER PURCHASE PHONE
  81.  
  82. ?>
Add Comment
Please, Sign In to add comment