Guest User

Untitled

a guest
Dec 25th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. Index.PHP:
  2. <!doctype html>
  3. <html lang="en">
  4. <head>
  5. <section class="main-container">
  6. <div class="main-wrapper">
  7. <form class="calendar-form" action="button.inc.php" method="POST">
  8. <meta charset="utf-8">
  9. <meta name="viewport" content="width=device-width, initial-scale=1">
  10. <title>jQuery UI Datepicker - Default functionality</title>
  11. <link rel="stylesheet"
  12. href="//code.jquery.com/ui/1.12.1/themes/base/jquery-
  13. ui.css">
  14. <link rel="stylesheet" href="/resources/demos/style.css">
  15. <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
  16. <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js">
  17. </script>
  18. <script>
  19. $( function() {
  20. $( "#datepicker" ).datepicker();
  21. } );
  22. </script>
  23. </head>
  24. <body>
  25.  
  26. <p>Date: <input type="text" id="datepicker"></p>
  27. <button type="submit" name="submit">Check Availability</button>
  28.  
  29. </body>
  30. </html>
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38. Button.inc.Php:
  39. <?php
  40. if (isset($_POST['submit'])) {
  41.  
  42. include_once 'dbh.inc.php';
  43.  
  44. $date = mysqli_real_escape_string($conn, $_POST['date']);
  45.  
  46.  
  47. if (empty($date)) {
  48. header("Location: ../calendar/index.php?index=empty");
  49. exit();
  50. } else {
  51.  
  52.  
  53.  
  54.  
  55. $sql = "INSERT INTO system (date) VALUES ('$date');";
  56. $result = mysqli_query($conn, $sql);
  57. header("Location: ../calendar/index.php?index=success");
  58. exit();
  59.  
  60.  
  61. }
  62.  
  63.  
  64.  
  65.  
  66. } else {
  67. header("Location: ../calendar/index.php");
  68. exit();
  69. }
  70.  
  71.  
  72. ?>
  73.  
  74.  
  75.  
  76. Dbh.inc.php:
  77.  
  78. <?php
  79.  
  80.  
  81. $dbServername = "localhost";
  82. $dbUsername = "root";
  83. $dbPassword = "";
  84. $dbName = "calendar";
  85.  
  86. $conn = mysqli_connect
  87. ($dbServername,$dbUsername,$dbPassword,$dbName);
Add Comment
Please, Sign In to add comment