Advertisement
theofficialdanny

Untitled

Nov 30th, 2017
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.88 KB | None | 0 0
  1. <?php
  2. session_start();
  3.  
  4. $servername = "localhost";
  5. $_SESSION['SERVER'] = $servername;
  6. $username = "placeholder";
  7. $_SESSION['USER'] = $username;
  8. $password = "";
  9. $_SESSION['PASS'] = $password;
  10. $dbname = "placeholder";
  11. $_SESSION['DB'] = $dbname;
  12.  
  13. $cookie_name = "password";
  14. $cookie_value = $password;
  15. setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/");
  16.  
  17. $conn = new mysqli($servername, $username, $password, $dbname);
  18.  
  19. if ($conn->connect_error) {
  20. die("Connection failed: " . $conn->connect_error);
  21. }
  22.  
  23. function add_customer ($FName, $LName, $Addr_City, $Addr_Street, $Addr_State, $Addr_Zip, $DoB, $PhoneNumber, $Email, $Special) {
  24. global $conn;
  25. $sql_i = "INSERT INTO Customer(FName, Lname, Addr_City, Addr_Street, Addr_State, Addr_Zip, DoB, PhoneNumber, Email_Address, Special) VALUES " . "('$FName', '$LName', '$Addr_City', '$Addr_Street', '$Addr_State', '$Addr_Zip', '$DoB', '$PhoneNumber', '$Email', '$Special')";
  26. run_update($sql_i); }
  27.  
  28. function add_Employee ($Fname, $LName, $Duty_Start, $Duty_End, $DoB, $Password) {
  29. global $conn;
  30. $sql_i = "INSERT INTO Employee(FName, LName, Duty_Start, Duty_End, DoB, Password) VALUES " . "('$FName', '$LName', '$Duty_Start', '$Duty_End', '$DoB', '$Password')";
  31. run_update($sql_i); }
  32.  
  33. function add_Flight ($DutyStart, $DepTime, $DepLocation, $ArrivalTime, $ArrivalLocation, $ResSeats, $AID, $Delayed, $Price) {
  34. global $conn;
  35. $sql_i = "INSERT INTO Flight(DutyStart, DepTime, DepLocation, ArrivalTime, ArrivalLocation, ResSeats, AID, Delayed, Price) VALUES " . "('$DutyStart', '$DepTime', '$DepLocation', '$ArrivalTime', '$ArrivalLocation', '$ResSeats', '$AID', '$Delayed', '$Price')";
  36. run_update($sql_i); }
  37.  
  38. function add_Ticket ($CID, $FID, $DiscountID, $TicketID, $Class, $Type, $SeatNo) {
  39. global $conn;
  40. $sql_i = "INSERT INTO Ticket(CID, FID, DiscountID, TicketID, Class, Type, SeatNo) VALUES " . "('$CID', '$FID', '$DiscountID', '$TicketID', '$Class', '$Type', '$SeatNo')";
  41. run_update($sql_i); }
  42.  
  43.  
  44. function run_select_Customer ($sql) {
  45. global $conn;
  46. $result = $conn->query($sql);
  47.  
  48. if ($result->num_rows > 0) {
  49. while($row = $result->fetch_assoc()) {
  50. echo "FName: " . $row["FName"] . " - LName: " . $row["Lname"] . " - Addr_City: " . $row["Addr_City"] . " - Addr_Street: " . $row["Addr_Street"] . " - Addr_State: " . $row["Addr_State"] . " - Addr_Zip: " . $row["Addr_Zip"] . " - DoB: " . $row["DoB"] . " - PhoneNumber: " . $row["PhoneNumber"] . " - Email: " . $row["Email"] . " - Special: " . $row["Special"] . "<br>";
  51. }
  52. }
  53.  
  54. else {
  55. echo "0 results";
  56. }
  57. }
  58. function run_select_Employee ($sql) {
  59. global $conn;
  60. $result = $conn->query($sql);
  61.  
  62. if ($result->num_rows > 0) {
  63. while($row = $result->fetch_assoc()) {
  64. echo "FName: " . $row["FName"] . " - LName: " . $row["Lname"] ." - Duty_Start: " . $row["Duty_Start"] . " - Duty_End: " . $row["Duty_End"] . " - DoB: " . $row["DoB"] . " - Password: " . $row["Password"] . "<br>";
  65. }
  66. }
  67.  
  68. else {
  69. echo "0 results";
  70. }
  71. }
  72.  
  73. function run_select_Flight ($sql) {
  74. global $conn;
  75. $result = $conn->query($sql);
  76.  
  77. if ($result->num_rows > 0) {
  78. while($row = $result->fetch_assoc()) {
  79. echo "DutyStart: " . $row["DutyStart"] . " - DepTime: " . $row["DepTime"] ." - DepLocation: " . $row["DepLocation"] . " - ArrivalTime: " . $row["ArrivalTime"] . " - ArrivalLocation: " . $row["ArrivalLocation"] . " - ResSeats: " . $row["ResSeats"] . " - AID: " . $row["AID"] . " - Delayed: " . $row["Delayed"] . " - Price: " . $row["Price"] . "<br>";
  80. }
  81. }
  82.  
  83. else {
  84. echo "0 results";
  85. }
  86. }
  87.  
  88.  
  89.  
  90. function get_Customer_Records (&$result) {
  91. global $conn;
  92.  
  93. $sql = "SELECT * FROM Customer";
  94.  
  95. if (($result = $conn->query($sql)) == TRUE) {
  96. echo "Database updated successfully <br>";
  97. }
  98.  
  99. else {
  100. echo "Error: " . $sql . "<br>" . $conn->error; }
  101. }
  102.  
  103. function get_Employee_Records (&$result) {
  104. global $conn;
  105.  
  106. $sql = "SELECT * FROM Employee";
  107.  
  108. if (($result = $conn->query($sql)) == TRUE) {
  109. echo "Database updated successfully <br>";
  110. }
  111.  
  112. else {
  113. echo "Error: " . $sql . "<br>" . $conn->error; }
  114. }
  115. function get_Flight_Records (&$result) {
  116. global $conn;
  117.  
  118. $sql = "SELECT * FROM Flight";
  119.  
  120. if (($result = $conn->query($sql)) == TRUE) {
  121. echo "Database updated successfully <br>";
  122. }
  123.  
  124. else {
  125. echo "Error: " . $sql . "<br>" . $conn->error; }
  126. }
  127.  
  128. function run_update ($sql) {
  129. global $conn;
  130.  
  131. if ($conn->query($sql) === TRUE) {
  132. echo "Database updated successfully <br>";
  133. }
  134.  
  135. else {
  136. echo "Error: " . $sql . "<br>" . $conn->error;
  137. }
  138. }
  139.  
  140. function check_login($EID, $pass, $msg) {
  141. global $conn;
  142. $msg = "Login Denied";
  143. $retvalue = False;
  144. $sql = "select password from Employee where EID = '$EID'";
  145. $result = $conn->query($sql);
  146.  
  147. if ($result->num_rows == 1) {
  148. $row = $result->fetch_assoc();
  149. $dbpass = $row["password"];
  150.  
  151. if ($dbpass == $pass) {
  152. $retvalue = True;
  153. $msg = "Login Successful";
  154. }
  155. }
  156.  
  157. return $retvalue;
  158. }
  159.  
  160. function delete_ticket ($TicketID) {
  161. global $conn;
  162.  
  163. $sql_i = "DELETE FROM Ticket WHERE TicketID='$TicketID'";
  164. run_update($sql_i);
  165. }
  166.  
  167. function delete_flight ($FID) {
  168. global $conn;
  169.  
  170. $sql_i = "DELETE FROM Flight WHERE FID='$FID'";
  171. run_update($sql_i);
  172. }
  173.  
  174. /*function calculate_refund {
  175. global $conn;
  176. //get cost from ticket, remove lost percentage. Drop box to find time remaining, possible other screen to notify user how much time is left.
  177. //$sql_i = "SELECT FROM Ticket"
  178. }
  179.  
  180. function calculate_cost (&$CID){
  181. global $conn;
  182. //add luggage, flight cost
  183. //subtract discount, membership, enter discount manually, membership entered manually
  184. //google: client side operations on multiple queries
  185. $sql_i = "SELECT Price FROM Luggage JOIN Flight WHERE CID='$CID'"
  186. } */
  187.  
  188. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement