Advertisement
tmen

runnerAbsencePost.php

Jan 7th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.78 KB | None | 0 0
  1. <!doctype html>
  2. <?php
  3. session_start();
  4. if(isset($_SESSION['status'])) {
  5. echo "<br>currently logged in: " . $_SESSION["name"] . ".<br>";
  6. }
  7. else
  8. {
  9. session_destroy();
  10. header("Location: runnerLoginForm.html");
  11. }
  12. ?>
  13. <html>
  14. <head>
  15. <meta charset="utf-8">
  16. <title>Untitled Document</title>
  17. </head>
  18.  
  19. <body>
  20. <style>
  21. body, html {
  22. height: 100%;
  23. background-color: azure;
  24. font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
  25. text-align: center;
  26. }
  27. div {
  28. border: 1px solid gray;
  29. padding: 8px;
  30. }
  31. h1 {
  32. text-align: center;
  33. text-transform: uppercase;
  34. color: #4CAF50;
  35. letter-spacing: 10px;
  36. text-size: 20px;
  37. }
  38. p {
  39. text-align: center;
  40. letter-spacing: 3px;
  41. }
  42. td, th {
  43. border: 1px solid green;
  44. padding: 0.5rem;
  45. text-align: center;
  46. }
  47. table {
  48. border-collapse: collapse;
  49. }
  50. a:link, a:visited {
  51. background-color: #4CAF50;
  52. color: white;
  53. padding: 14px 25px;
  54. text-align: center;
  55. text-decoration: none;
  56. display: inline-block;
  57. }
  58. a:hover, a:active {
  59. background-color: #4CAF50;
  60. }
  61. </style>
  62. </style>
  63. <h1>XC Attendance
  64. </h1>
  65. <p>
  66. <a href="runnerHome.php">Your Log</a>
  67. <a href="absencePostForm.html">Post your absence</a>
  68. <a href="runnerHome.php?hello=true">Logout</a>
  69. </p>
  70. <br>
  71. <?php
  72. function logout() {
  73. session_destroy();
  74. //echo "refreshing";
  75. header("Location: auctionLoginForm.html");
  76. }
  77. if (isset($_GET['hello']))
  78. {
  79. logout();
  80. //setcookie("user", "", time() - 3600);
  81. }
  82. echo "<br>currently logged in: " . $_SESSION["name"] . "<br>";
  83. function sanitize($data)
  84. {
  85. // apply stripslashes if magic_quotes_gpc is enabled
  86. if(get_magic_quotes_gpc())
  87. {
  88. $data = stripslashes($data);
  89. }
  90. return $data;
  91. }
  92. $pers = $_SESSION["name"];
  93. $servername = "localhost";
  94. $username = "playground18";
  95. $password = "Cdz5SOVrY2p8fnWS";
  96. $dbname = "playground18";
  97. $date = $_GET['date'];
  98. $description = $_GET['description'];
  99.  
  100. try {
  101. $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
  102. // set the PDO error mode to exception
  103. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  104. $sql = "INSERT INTO tanay_xcatt_absences (person, absence_date, explanation)
  105. VALUES ('$pers', '$date', '$description')";
  106. // use exec() because no results are returned
  107. $conn->exec($sql);
  108. echo "New absence posted successfully";
  109. }
  110. catch(PDOException $e)
  111. {
  112. echo $sql . "<br>" . $e->getMessage();
  113. }
  114.  
  115. $conn = null;
  116.  
  117. ?>
  118. </body>
  119. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement