Advertisement
Guest User

Untitled

a guest
Mar 12th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.81 KB | None | 0 0
  1. <?php
  2. session_start();
  3. if ( !isset( $_SESSION["id"] )) {
  4. header("Location: index.php");
  5. }
  6. ?>
  7. <!DOCTYPE html>
  8. <html>
  9. <head>
  10. <title>Verander uw planning</title>
  11. <link rel="stylesheet" type="text/css" href="style.css">
  12. <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
  13. <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
  14. <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
  15. <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>
  16. </head>
  17. <body>
  18. <div class="list">
  19. <h4 id="titel1">Uw opgeslagen ideeën worden hier beneden weergeven.</h4>
  20. <?php
  21.  
  22. $server = "localhost";
  23. $db = "wptexamen";
  24. $username = "root";
  25. $password = "";
  26.  
  27. $conn = new PDO( "mysql:host=$server;dbname=$db", $username, $password );
  28. $conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
  29. //prepares the correct sql/selection from the db
  30. $sql = "SELECT weekplan.id, weekplan.dag, weekplan.oefening, weekplan.user_id FROM weekplan, user WHERE weekplan.id = ? AND user.id = ?";
  31. $stmt = $conn->prepare($sql);
  32. $stmt->bindParam( 1, $_GET["id"] ); //Selected ID from the list of ideas
  33. $stmt->bindParam(2, $_SESSION["id"]); //Current user's ID
  34. $stmt->execute();
  35.  
  36. $result = $stmt->fetch();//If there is a planning with this ID for this user
  37. function getDayFromNumber( $dayNum ) {
  38. switch( $dayNum ) {
  39. case 1:
  40. return "Maandag";
  41. case 2:
  42. return "Dinsdag";
  43. case 3:
  44. return "Woensdag";
  45. case 4:
  46. return "Donderdag";
  47. case 5:
  48. return "Vrijdag";
  49. case 6:
  50. return "Zaterdag";
  51. case 7:
  52. return "Zondag";
  53.  
  54. default:
  55. return null;
  56. }
  57. }
  58.  
  59. if (isset($result)) {
  60. echo '
  61. <form class="" action="saveIdee.php" method="post">
  62. <div class="form-group">
  63. <select class="form-control" id="exampleFormControlSelect1" name="dag">
  64. <option value="1" ' . $result["dag"] == 1 ? 'selected="selected"' : null . '>Maandag</option>
  65. <option value="2" ' . $result["dag"] == 2 ? 'selected="selected"' : null . '>Dinsdag</option>
  66. <option value="3" ' . $result["dag"] == 3 ? 'selected="selected"' : null . '>Woensdag</option>
  67. <option value="4" ' . $result["dag"] == 4 ? 'selected="selected"' : null . '>Donderdag</option>
  68. <option value="5" ' . $result["dag"] == 5 ? 'selected="selected"' : null . '>Vrijdag</option>
  69. <option value="6" ' . $result["dag"] == 6 ? 'selected="selected"' : null . '>Zaterdag</option>
  70. <option value="7" ' . $result["dag"] == 7 ? 'selected="selected"' : null . '>Zondag</option>
  71. </select>
  72. <div class="form-group">
  73. <label id="titel1" for="idee">Oefeningen</label>
  74. <textarea class="form-control" name="idee" id="idee" rows="10">
  75. ' . $result["oefening"] . '
  76. </textarea>
  77. </div>
  78. <input type="hidden" name="id" value="' . $result["id"] . '" />
  79. <input type="submit" class="form-control" value="Sla op" />
  80. </form>
  81. ';
  82. }
  83. ;
  84. ?>
  85. <a href="bekijk.php">Terug naar bekijk planning</a>
  86. <a href="signout.php">Log uit</a>
  87. </div>
  88. </body>
  89. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement