PageRenderTime 55ms CodeModel.GetById 28ms RepoModel.GetById 1ms app.codeStats 0ms

/middCalendar/insert1.php

https://github.com/gkipkorir/public_html
PHP | 155 lines | 136 code | 15 blank | 4 comment | 5 complexity | f61b916429f3ef3672618eb1f4c9af7e MD5 | raw file
  1. <?php session_start(); ?>
  2. <!DOCTYPE HTML>
  3. <html>
  4. <head>
  5. <style>
  6. .logo {
  7. position: fixed;
  8. margin-top: 1%;
  9. margin-left: 38%;
  10. z-index: 2;
  11. opacity: .6;
  12. }
  13. .header {
  14. position:fixed;
  15. background-color:gray;
  16. opacity: .9;
  17. width:100%;
  18. padding-top: 20px;
  19. padding-bottom: 20px;
  20. padding-right: 10%;
  21. padding-left: 10%;
  22. border-width: 3px;
  23. border-color: black;
  24. margin-top: 10%;
  25. margin-right: 0%;
  26. margin-left: 0%;
  27. z-index: 1;
  28. }
  29. .headerText {
  30. float: left;
  31. color: white;
  32. width: 13%
  33. }
  34. .center {
  35. color:black;
  36. text-align:center;
  37. }
  38. .main {
  39. position: fixed;
  40. background-color: white;
  41. opacity: .8;
  42. width: 60%;
  43. height: 500px;
  44. overflow-y: scroll;
  45. padding-top: 5%;
  46. padding-bottom: 5%;
  47. padding-right: 10%;
  48. padding-left: 10%;
  49. border-width: 3px;
  50. border-color: black;
  51. border-radius: 25px;
  52. margin-top: 15%;
  53. margin-bottom: 5%;
  54. margin-right: 10%;
  55. margin-left: 10%;
  56. z-index = -1;
  57. }
  58. p {
  59. font-family:"Times New Roman";
  60. font-size:20px;
  61. }
  62. a:link {
  63. font-size: 1em;
  64. font-weight: normal;
  65. color: white;
  66. text-decoration:none;
  67. }
  68. a:visited {
  69. font-size: 1em;
  70. font-weight: normal;
  71. color: white;
  72. text-decoration:none;
  73. }
  74. a:hover {
  75. font-size: 1.2em;
  76. font-weight: bold;
  77. color: white;
  78. text-decoration:none;
  79. }
  80. a:active {
  81. font-size: 1.2em;
  82. font-weight: bold;
  83. color: white;
  84. text-decoration:none;
  85. }
  86. </style>
  87. </head>
  88. <body background=1003background1.png>
  89. <div class="logo">
  90. <img src=MiddleburyPanther.jpg width="400px" height="145px">
  91. </div>
  92. <div class="header">
  93. <?php
  94. define('DB_SERVER','panther.cs.middlebury.edu');
  95. define('DB_USERNAME','wschaaf');
  96. define('DB_PASSWORD','wschaaf');
  97. define('DB_DATABASE','wschaaf_Calendar');
  98. $con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_DATABASE) or die("Could not connect");
  99. if(isset($_SESSION['User'])){
  100. echo "<div class=headerText>Welcome ".$_SESSION['User']."</div>";
  101. echo "<div class=headerText><a href='./events.php'>Home</a></div>";
  102. echo "<div class=headerText><a href='./logout.php'>Logout</a></div>";
  103. echo "<form method='POST' action='insert1.php'> <input type='text' name='Search' >
  104. <input type='submit' value='Search'>
  105. </form>";
  106. }
  107. else {
  108. //if session user is not set, show link to log in and to create user
  109. $_SESSION['User'] = null;
  110. echo "<div class=headerText><a href='./events.php'>Home</a></div>";
  111. echo "<div class=headerText><a href='./login.php'>Log In</a></div>";
  112. echo "<form method='POST' action='insert1.php'> <input type='text' name='Search' >
  113. <input type='submit' value='Search'>
  114. </form>";
  115. }
  116. ?>
  117. </div>
  118. <div class="main">
  119. <?php
  120. //set up the connection to the database
  121. define('DB_SERVER', 'panther.cs.middlebury.edu');
  122. define('DB_USERNAME', 'wschaaf');
  123. define('DB_PASSWORD', 'wschaaf');
  124. define('DB_DATABASE', 'wschaaf_Calendar');
  125. $search = htmlspecialchars($_POST[Search]);
  126. $con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_DATABASE) or die ("could not connect");
  127. $sql="SELECT * FROM Events WHERE name LIKE '%$search%'";
  128. if (!mysqli_query($con, $sql)) {
  129. die('Error: ' . mysqli_error($con));
  130. }
  131. else {
  132. //execute the SQL query
  133. $result = mysqli_query($con,$sql);
  134. }
  135. while ($row = mysqli_fetch_array($result)) {
  136. //print result
  137. echo "<p>".$row['name']."</p> </br>Location: ".$row['location']." </br>Date: ".$row['date']." </br> Time: ".$row['time']." </br> Genre: ".$row['genre']." </br> Description: ".$row['description']."</br> </br>";
  138. }
  139. ?>
  140. </div>