Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. <?php
  2. require_once 'config.php';
  3. error_reporting(E_ALL & ~E_NOTICE);
  4. ?>
  5.  
  6. <!DOCTYPE html>
  7. <html>
  8. <head>
  9. <title>insert date</title>
  10. <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  11. <meta charset="UTF-8">
  12. <!-- Include CSS File Here-->
  13. <link href="style3.css" rel="stylesheet">
  14. </head>
  15. <body>
  16.  
  17. <form method = 'post'>
  18.  
  19. <h3>Date:
  20. <input type = 'date' class = 'date' maxlength = '17' placeholder = '11-04-2019 17:20' name = 'date[]' required>
  21. </h3>
  22.  
  23. <?php
  24. <!-- Date example: 03-04-2019 14:48 -->
  25. $date = date("d-m-Y H:i", strtotime("+2 hours"));
  26. //date('Y-m-d H:i:s', strtotime($date));
  27. //date('d-m-Y H:i', strtotime($date));
  28. $plus2hrs = date("d-m-Y H:i", strtotime("+2 hours"));
  29. //d - Day of the month, 2 digits with leading zeros
  30. //m - Numeric representation of a month, with leading zeros
  31. //Y - A full numeric representation of a year, 4 digits
  32. //h - 12-hour format of an hour with leading zeros
  33. //i - Minutes with leading zeros
  34. //a - Lowercase Ante meridiem and Post meridiem
  35.  
  36. //MySQL Database Connect
  37. include 'config.php';
  38.  
  39. // Check if date form is submitted successfully
  40. if(isset($_POST["submit"]))
  41. {
  42. // Check if any option is selected
  43. if(isset($_POST["date"]))
  44. {
  45. // Retrieving each selected option
  46. foreach ($_POST['date'] as $date)
  47. //print "<br/>on the <b/>$date</b/>";
  48. print "<br/>on the <b/>$date</b/>";
  49. }
  50. else
  51. print "<br/>Select an option first !!";
  52. }
  53.  
  54. // Create connection
  55. $conn = new mysqli($servername, $username, $password, $dbname);
  56. // Check connection
  57. if ($conn->connect_error) {
  58. die("Connection failed: " . $conn->connect_error);
  59. }
  60.  
  61. // Now post entries also into DB
  62. if(isset($_POST["submit"])) {
  63. {
  64. // Retrieving each selected option
  65. foreach ($_POST['date'] as $date) {
  66. $sql = "INSERT INTO `$dbname`.`$table` (`date`) VALUES ('$date')";
  67. }
  68. }
  69. $conn->close();
  70. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement