Advertisement
Guest User

verwerking

a guest
Apr 3rd, 2018
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.91 KB | None | 0 0
  1. <?php
  2.  
  3. session_start();
  4.  
  5.  
  6. // kijken of je wel bent ingelogt!
  7. if(!$_SESSION['naam']){
  8.         Header('location: login.php');
  9. }
  10. ?>
  11.  
  12.  
  13. <!DOCTYPE html>
  14. <html lang="en">
  15.     <head>
  16.         <meta charset="utf-8">
  17.         <title>Het Bibliotheek huis</title>
  18.        
  19.         <meta name="viewport" content="width=device-width, initial-scale=1">
  20.        
  21.                 <!-- Latest compiled and minified CSS -->
  22.                 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  23.  
  24.                 <!-- jQuery library -->
  25.                 <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  26.  
  27.                 <!-- Latest compiled JavaScript -->
  28.                 <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  29.                
  30.                 <!-- Eigen CSS voor extra content -->
  31.                 <link rel="stylesheet" href="bieb.css">
  32.                
  33.                
  34.     </head>
  35.     <body>
  36.         <!-- Navbar Materiaal -->
  37.         <nav class="navbar navbar-inverse">
  38.             <div class="container-fluid">
  39.             <div class="navbar-header">
  40.         <a class="navbar-brand" href="index.php"> Het Bibliotheek Huis</a>
  41.             </div>
  42.         <ul class="nav navbar-nav">
  43.             <li><a href="klantindex.php"class="tekstkleur">Home</a></li>
  44.             <li class="dropdown">
  45.         <a class="dropdown-toggle" data-toggle="dropdown" href="#" class="tekstkleur">Genre Boeken<span class="caret"></span></a>
  46.        
  47.             <ul class="dropdown-menu">
  48.             <li class="ddkleur"><a href="comedy2.php">Comedy boeken</a></li>
  49.             <li class="ddkleur"><a href="horror2.php">Horror boeken</a></li>
  50.             <li class="ddkleur"><a href="drama2.php">Drama boeken </a></li>
  51.             <li class="ddkleur"><a href="thriller2.php">Thriller boeken</a></li>
  52.             <li class="ddkleur"><a href="fantasie2.php">Fantasie boeken</a></li>
  53.             </ul>
  54.             </li>
  55.                         <ul class="nav navbar-nav navbar-right">
  56.                     <?php
  57.               error_reporting(0);
  58.               if($_SESSION['inlog'] == "klant" || $_SESSION['inlog'] == "admin") {
  59.               ?>
  60.               <li><a href="uitloggen.php"><span class="glyphicon glyphicon-log-out"></span> Uitloggen</a></li>
  61.             <?php
  62.           }
  63.             else {
  64.               ?>
  65.                 <li><a href="signin.php"><span class="glyphicon glyphicon-log-in"></span> Inloggen</a></li>
  66.               <?php
  67.             }
  68.             ?>
  69.                 </ul>
  70.             <li><a class="dropdown-toggle" data-toggle="dropdown"href="#" class="tekstkleur">Informatie<span class="caret"></span></a>
  71.             <ul class="dropdown-menu">
  72.             <li class="ddkleur"><a href="informatievraag3.2.php">Toon een overzicht van de boeken die het <strong>minst</strong> zijn geleend. </a></li>
  73.             <li class="ddkleur"><a href="informatievraag9.2.php">Toon de meest geleende boeken van een schrijver/schrijfster.</a></li>
  74.             </ul>
  75.            
  76.             <li><a class="dropdown-toggle" data-toggle="dropdown"href="#" class="tekstkleur"><span class="glyphicon glyphicon-user"> <?php echo $_SESSION['naam']; ?><span class="caret"></span></a>
  77.             <ul class="dropdown-menu">
  78.             <li class="ddkleur"><a href="inzien.php">Bestellingen inzien</a></li>
  79.             <li class="ddkleur"><a href="www.php">Wachtwoord wijzigen</a></li>
  80.             </ul>
  81.             </li>
  82.  
  83.  
  84.            
  85.            
  86.             <form class="navbar-form navbar-left" method="post" action="zoeken1.php">
  87.                 <div class="input-group">
  88.                 <input type="text" class="form-control" placeholder="Zoek voor een boek.." name="search">
  89.                 <div class="input-group-btn">
  90.                 <button class="btn btn-default" type="submit">
  91.                 <i class="glyphicon glyphicon-search"></i>
  92.           </button>
  93.  
  94.             </div>
  95.             </div>
  96.             </form>
  97.             </div>
  98.         </nav>
  99.        
  100.         <?php
  101.     if(isset($_POST['search']))
  102.     {
  103.       $_SESSION['search'] = $_POST['search'];
  104.     }
  105.  
  106.     ?>
  107.         <!-- Homescreen afbeelding -->
  108.        
  109.        
  110.        
  111.             <div class="container-fluid">
  112.                 <img class="img-responsive" src="boek.jpg" alt="boek">
  113.             </div>
  114.         <div class="topnav">
  115.         <a></a>
  116. <center>       
  117.        
  118.        
  119.        
  120.         <?php
  121.        
  122.         error_reporting(E_ALL);
  123.        
  124.        
  125.         $servername = "localhost";
  126.         $username = "root";
  127.         $password = "";
  128.         $dbname = "bibliotheek";
  129.        
  130.         $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
  131.         //$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  132.        
  133.         if($_GET['boekid']){
  134.             $boekid = $_GET['boekid'];
  135.            
  136.            
  137.             $deboektitel = $conn->prepare("SELECT titel FROM boek WHERE idboek = :id");
  138.             $deboektitel->bindParam(':id', $boekid);
  139.             $deboektitel->execute();
  140.            
  141.             if ($deboektitel->rowCount() >= 1){
  142.                 $boekinfo = $deboektitel->fetch();
  143.                
  144.                 $boektitel = $boekinfo['titel'];
  145.                
  146.                 // Klantnummer krijgen
  147.                 $klantnummer = $conn->prepare("SELECT klantnummer FROM klant WHERE naam = :name");
  148.                 $klantnummer->bindParam(':name', $_SESSION['naam']);
  149.                 $klantnummer->execute();
  150.                 $klantinfo = $klantnummer->fetch();
  151.                
  152.                 $klantnum = $klantinfo['klantnummer'];
  153.                
  154.                
  155.                 $leenhoeveelheid = 1; // standaard 1 even gezet 1 boek per keer lenen?
  156.                
  157.                 $leendatum = date('Y-m-d');
  158.                 $returndatum = date('Y-m-d', strtotime("+30 days"));
  159.                
  160.                 $query = $conn->prepare("INSERT INTO geleend(idboek, titel, leendatum, returndatum, klantnummer, leenhoeveelheid) VALUES(:idboek, :titel, :leendatum, :returndatum, :klantnummer, :leenhoeveelheid)");
  161.                 if ($query->execute(array(
  162.                     "idboek" => $boekid,
  163.                     "titel" => $boektitel,
  164.                     "leendatum" => $leendatum,
  165.                     "returndatum" => $returndatum,
  166.                     "klantnummer" => $klantnum,
  167.                     "leenhoeveelheid" => $leenhoeveelheid
  168.                 ))){
  169.                     echo '<p class="tekstbv"> U heeft het boek geleend</p>';
  170.                 }else{
  171.                     echo '<p class="tekstbv"> Helaas is er een fout opgetreden. Probeer het later opnieuw!</p>';
  172.                 }
  173.             }else{
  174.                 echo '<p class="tekstbv"> Helaas komt dit boek niet voor in ons bibliotheek. Probeer een andere boek!</p>';
  175.             }
  176.         }else{
  177.             echo '<p class="tekstbv"> Geen boek id!</p>';
  178.         }
  179.        
  180.         ?>
  181.        
  182. </center>
  183.  
  184.  
  185.  
  186.         <br>
  187.  
  188.  
  189.  
  190.        
  191.         <footer class="fixed-bottom"><br><strong><i>Alle rechten behoren toe tot &copy Ryan Buitenhuis, 2018.</stong><i> </footer>
  192.     </body>
  193. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement