Advertisement
Guest User

Untitled

a guest
Oct 5th, 2017
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. //Finds the most recently inputted infrastructure by a user and then updates that table
  2.  
  3. <?php
  4. session_start();
  5.  
  6. // gets cost, username and selected infrastructure
  7. $cost = $_GET['hidden'];
  8.  
  9. $username = $_SESSION['loggedin'];
  10.  
  11. $One = $_GET['service'];
  12.  
  13. //Packages
  14. $p1 = $_GET['p1'];
  15. $p2 = $_GET['p2'];
  16. $p3 = $_GET['p3'];
  17. $p4 = $_GET['p4'];
  18. $p5 = $_GET['p5'];
  19. $p6 = $_GET['p6'];
  20. $p7 = $_GET['p7'];
  21. $p8 = $_GET['p8'];
  22. $p9 = $_GET['p9'];
  23. $p10 = $_GET['p10'];
  24. $p11 = $_GET['p11'];
  25. $p12 = $_GET['p12'];
  26. $p13 = $_GET['p13'];
  27. $p14 = $_GET['p14'];
  28. $p15 = $_GET['p15'];
  29. $p16 = $_GET['p16'];
  30. $p17 = $_GET['p17'];
  31. $p18 = $_GET['p18'];
  32. $p19 = $_GET['p19'];
  33. $p20 = $_GET['p20'];
  34. $p21 = $_GET['p21'];
  35.  
  36. $Five = $_GET['servers'];
  37. $Two = $_GET['ram'];
  38. $Six = $_GET['vm'];
  39.  
  40. $Seven = $_GET['cpu'];
  41.  
  42. // connects to database
  43. $dbuser = "[database username]";
  44. $dbpass = "[database password]";
  45. $db = "SSID";
  46. $connect = oci_connect($dbuser, $dbpass, $db);
  47.  
  48. if (!$connect) {
  49. echo "An error occurred connecting to the database";
  50. exit;
  51. }
  52.  
  53. // finds most recent infrastructure of this user
  54. $sqlTwo = "SELECT MAX(ID) FROM infrastructure WHERE USERNAME = '{$username}'";
  55. $stmtTwo = oci_parse($connect, $sqlTwo);
  56. oci_execute($stmtTwo);
  57.  
  58. $currentID = "";
  59. while(oci_fetch_array($stmtTwo)) {
  60. $id = oci_result($stmtTwo,"MAX(ID)");
  61. $currentID = $id;
  62. }
  63.  
  64. oci_close($connect);
  65.  
  66. // checks if getting ID was successful or not
  67. if ($currentID != ""){
  68.  
  69. $connect = oci_connect($dbuser, $dbpass, $db);
  70.  
  71. // updates the current infrastructure with new values
  72. $sqlTwo = "UPDATE infrastructure SET
  73. COST = '{$cost}',
  74. SERVICE = '{$One}',
  75. RAM = '{$Two}',
  76. PACKAGEONE = '{$p1}',
  77. PACKAGETWO = '{$p2}',
  78. PACKAGETHREE = '{$p3}',
  79. PACKAGEFOUR = '{$p4}',
  80. PACKAGEFIVE = '{$p5}',
  81. PACKAGESIX = '{$p6}',
  82. PACKAGESEVEN = '{$p7}',
  83. PACKAGEEIGHT = '{$p8}',
  84. PACKAGENINE = '{$p9}',
  85. PACKAGETEN = '{$p10}',
  86. PACKAGEELEVEN = '{$p11}',
  87. PACKAGETWELVE = '{$p12}',
  88. PACKAGETHIRTEEN = '{$p13}',
  89. PACKAGEFOURTEEN = '{$p14}',
  90. PACKAGEFIFTEEN = '{$p15}',
  91. PACKAGESIXTEEN = '{$p16}',
  92. PACKAGESEVENTEEN = '{$p17}',
  93. PACKAGEEIGHTTEEN = '{$p18}',
  94. PACKAGENINETEEN = '{$p19}',
  95. PACKAGETWENTY = '{$p20}',
  96. PACKAGETWENTYONE = '{$p21}',
  97. SERVERS = 'null',
  98. VM = '{$Six}',
  99. CPU = '{$Seven}'
  100. WHERE ID = '{$current}'";
  101.  
  102. $stmtTwo = oci_parse($connect, $sqlTwo);
  103.  
  104. oci_execute($stmtTwo);
  105.  
  106. // directs user to monitoring page
  107. header('location: monitoringPage.php?');
  108. }
  109. else
  110. {
  111. header('location: monitoringPage.php?');
  112. }
  113. oci_close($connect);
  114.  
  115. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement