Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.89 KB | None | 0 0
  1. <?php
  2.  
  3. $servername = "localhost";
  4. $username = "root";
  5. $password = "cornwall";
  6.  
  7. $con=mysqli_connect('localhost','root','cornwall','ibill');
  8. // This code creates a connection to the MySQL database in PHPMyAdmin named 'ibill':
  9.  
  10. if (mysqli_connect_errno()) {
  11. echo "Failed to connect to MySQL: " . mysqli_connect_error();
  12. }
  13. // The connection is then checked, if it fails, an echo is sent back to the page stating a connection error.
  14.  
  15. if(!empty($_POST))
  16. {
  17. $typeofactivity = $_POST['typeofactivity'];
  18. $employer = $_POST['employer'];
  19. $date = $_POST['date'];
  20. $time = $_POST['time'];
  21. $amount = $_POST['amount'];
  22. $errorMessage = "";
  23.  
  24. if(empty($typeofactivity)) {
  25. $errorMessage .= "<li>You forgot to enter an activity!</li>";
  26. }
  27. if(empty($employer)) {
  28. $errorMessage .= "<li>You forgot to enter an employer!</li>";
  29. }
  30. if(empty($date)) {
  31. $errorMessage .= "<li>You forgot to select the date!</li>";
  32. }
  33. if(empty($time)) {
  34. $errorMessage .= "<li>You forgot to select the time!</li>";
  35. }
  36. if(empty($amount)) {
  37. $errorMessage .= "<li>You forgot to select the amount of the session!</li>";
  38. }
  39.  
  40. $record_session = "INSERT INTO session_details (typeofactivity, employer, date, time, amount) VALUES ('$typeofactivity', '$employer', '$date', '$time', '$amount')";
  41. mysqli_query($con, $record_session);
  42. }
  43.  
  44. /** Error reporting */
  45. error_reporting(E_ALL);
  46. ini_set('display_errors', 1);
  47. ini_set('display_startup_errors', 1);
  48.  
  49. header('Location: main.php#sessionrecordsuccess');
  50. exit();
  51. ?>
  52.  
  53. <!--********************************RECORD SESSION PAGE SUCCESS************************************-->
  54. <!--***************************************************************************************-->
  55.  
  56. <!--********************************HEADER**********************************************-->
  57. <div data-role="page" id="sessionrecordsuccess">
  58. <div data-role="header" data-id="foo1" data-position="fixed">
  59. <div class='cssmenu'>
  60. <ul>
  61. <li class='active'><a href='#home'>Home</a></li>
  62. <li><a href='#sessionrecord'>Record a Session</a></li>
  63. <li><a href='#viewsessions'>View Sessions</a></li>
  64. <li><a href='#email'>E-mail an Invoice</a></li>
  65. </ul>
  66. </div>
  67. </div><!-- /header -->
  68. <!--********************************HEADER**********************************************-->
  69.  
  70. <!--********************************MAIN**********************************************-->
  71. <div data-role="main" class="ui-content">
  72.  
  73. <img class="mainlogo" src="/projects/ibill_v3/img/ibill logo.png" alt="iBill Logo" width="250" height="190">
  74.  
  75. <section class="maincontent">
  76. <h1>Record a session using the form below</h1>
  77. <P>Session logged successfully! <br>Record another...</p>
  78. <form method="post" action="record_session.php" id="sessionRecord">
  79. <fieldset>
  80. <select name="typeofactivity" id="typeofactivity" data-native-menu="false">
  81. <option>Type of Session</option>
  82. <option value="Surf">Surf</option>
  83. <option value="Coasteer">Coasteer</option>
  84. <option value="Bodyboard">Bodyboard</option>
  85. <option value="Cornish Challenge">Cornish Challenge</option>
  86. </select>
  87. </fieldset>
  88. <fieldset>
  89. <select name="employer" id="employer" data-native-menu="false">
  90. <option>Employer</option>
  91. <option value="Newquay Activity Centre">Newquay Activity Centre</option>
  92. <option value="Coastline Coasteer">Coastline Coasteer</option>
  93. </select>
  94. </fieldset>
  95. <label for="date">Date of Session</label>
  96. <input type="date" data-clear-btn="false" name="date" id="date" value="">
  97.  
  98. <label for="time">Time of Session</label>
  99. <input type="time" data-clear-btn="false" name="time" id="time" value="">
  100.  
  101. <label for="amount">Amount (GBP)</label>
  102. <input type="number" data-clear-btn="true" name="amount" id="amount" value="">
  103. <div id="submitbutton">
  104. <input type="submit" name="formSubmit" value="Submit">
  105. </div>
  106. </form>
  107.  
  108. </section>
  109. </div>
  110. <!--********************************MAIN**********************************************-->
  111.  
  112. <!--********************************FOOTER**********************************************-->
  113. <div data-role="footer">
  114. <footer class="footer">
  115. <p>awilliams&copy;</p>
  116. </footer>
  117. </div>
  118. </div>
  119. <!--********************************FOOTER**********************************************-->
  120.  
  121. <!--********************************END OF RECORD SESSION PAGE SUCCESS************************************-->
  122. <!--***************************************************************************************-->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement