Advertisement
Guest User

Untitled

a guest
Oct 4th, 2015
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.02 KB | None | 0 0
  1. <?php
  2. error_reporting(1);
  3. require "config.php";
  4. session_start();
  5. if (!(isset($_SESSION["username"]) && $_SESSION["username"] === md5(USERNAME) && isset($_SESSION["password"]) && $_SESSION["password"] === md5(PASSWORD))) {
  6. header("Location:index.php");
  7. }
  8.  
  9. $year = date("Y");
  10. $month = date("m");
  11. $day = date("d");
  12.  
  13. if ($_POST["ymd"]) {
  14. $year = h($_POST["year"]);
  15. $month = h($_POST["month"]);
  16. $day = h($_POST["day"]);
  17. }
  18.  
  19. $ymd = $year.$month.$day;
  20.  
  21. ?>
  22. <!DOCTYPE html>
  23. <html lang="ja">
  24. <head>
  25. <meta charset="utf-8">
  26. <title>フットサル予定表</title>
  27. <link rel="stylesheet" href="event-calendar.css">
  28. </head>
  29.  
  30. <body>
  31. <div id="calendarWrap">
  32. <?php
  33. print "<div id=\"selectBox\">\n";
  34. print "<form action=\"{$_SERVER["PHP_SELF"]}\" method=\"post\">\n";
  35. print "<div class=\"selectBoxItem\">\n";
  36. print "<select name=\"year\">\n";
  37. for ($ovy = $year -1; $ovy <= $year + 1; $ovy++) {
  38. if ($ovy == date("Y")) {
  39. print "<option value=\"{$ovy}\" selected=\"selected\">{$ovy}</option>\n";
  40. } else {
  41. print "<option value=\"{$ovy}\">{$ovy}</option>\n";
  42. }
  43. }
  44. print "</select>\n";
  45. print "年\n";
  46. print "</div>\n";
  47.  
  48. print "<div class=\"selectBoxItem\">\n";
  49. print "<select name=\"month\">\n";
  50. for ($ovm = 1; $ovm <= 12; $ovm++) {
  51. $ovm = sprintf("%02d",$ovm);
  52. if ($ovm == date("m")) {
  53. print "<option value=\"{$ovm}\" selected=\"selected\">{$ovm}</option>\n";
  54. } else {
  55. print "<option value=\"{$ovm}\">{$ovm}</option>\n";
  56. }
  57. }
  58. print "</select>\n";
  59. print "月\n";
  60. print "</div>\n";
  61.  
  62. print "<div class=\"selectBoxItem\">\n";
  63. print "<select name=\"day\">\n";
  64. for ($ovd = 1; $ovd <= 31; $ovd++) {
  65. $ovd = sprintf("%02d",$ovd);
  66. if ($ovd == date("d")) {
  67. print "<option value=\"{$ovd}\" selected=\"selected\">{$ovd}</option>\n";
  68. } else {
  69. print "<option value=\"{$ovd}\">{$ovd}</option>\n";
  70. }
  71. }
  72. print "</select>\n";
  73. print "日\n";
  74. print "</div>\n";
  75.  
  76. print "<p><input type=\"submit\" name=\"ymd\" value=\"年月を変更\"></p>\n";
  77. print "</form>\n";
  78. print "</div>\n";
  79.  
  80. $db = mysql_connect('サーバー名', 'user', 'PASS');
  81. mysql_select_db("");
  82. $result = mysql_query("SELECT * FROM events WHERE jikan=$ymd");
  83. while ($value = mysql_fetch_assoc($result, MYSQL_ASSOC)) {
  84. $title = $value["title"];
  85. $content = $value["naiyo"];
  86. break;
  87. }
  88. mysql_close($db);
  89.  
  90. print <<< EOM
  91. <h3>{$year}年{$month}月{$day}日の予定</h3>
  92. <form action="submit.php" method="post">
  93. <p id="inputTitle"><input type="text" name="title" value="{$title}"></p>
  94. <p id="inputText"><textarea cols="50" rows="7" name="content" value="{$content}">{$content}</textarea><p>
  95. <p><input type="hidden" name="ymd" value="{$ymd}"></p>
  96. <p id="wd"><button type="submit" name="write" value="write"><img src="button_write.png"></button><button type="submit" name="delete" value="delete"><img src="button_delete.png"></button></p>
  97. </form>
  98. EOM;
  99.  
  100. function h($str) {
  101. return htmlspecialchars($str,ENT_QUOTES,"utf-8");
  102. }
  103. ?>
  104. <div id="calendarFt">
  105. <p><a href="team.php">予定表に戻る</a><a href="logout.php">ログアウト</a></p>
  106. </div>
  107. </div>
  108. </body>
  109. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement