Advertisement
Guest User

Untitled

a guest
Dec 18th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 15.62 KB | None | 0 0
  1. addlocatie
  2.  
  3. <?php
  4.     include_once 'header.php';
  5. ?>
  6.  
  7. <div class="container">
  8.      <div class="panel panel-warning">
  9.         <div class="panel-heading">Locatie toevoegen</div>
  10.             <div class="panel-body">
  11.  
  12.  
  13.  
  14. <form action="/addlocatieact.php" method="POST">
  15.  
  16. <label class= "control-label"><b>Naam van locatie</b></label>
  17. <input type ="text" class="form-control" placeholder="Hoek van Holland afdeling" name="locatienaam" required>
  18.  
  19. <label class="control-label"><b>Adres</b></label>
  20. <input type="text" class="form-control" name="adres" required>
  21.  
  22. <label class="control-label"><b>Postcode</b></label>
  23. <input type="text" class="form-control" name="postcode" required>
  24.  
  25. <label class="control-label"><b>Plaats</b></label>
  26. <input type="text" class="form-control"  name="plaats" required>
  27. </p>
  28. <button type="submit" class="btn btn-primary" name="submit">Submit</button>
  29. </p>
  30. </form>
  31. </div>
  32. </div>
  33. </div>
  34. </div>
  35.  
  36.  
  37. <?php
  38.     include_once 'footer.php';
  39. ?>
  40.  
  41.  
  42. addvoorraad
  43.  
  44.  
  45. <?php
  46.     include_once 'header.php';
  47. ?>
  48.  
  49. <div class="container">
  50.      <div class="panel panel-warning">
  51.         <div class="panel-heading">Voorraad toevoegen</div>
  52.             <div class="panel-body">
  53.  
  54.  
  55.  
  56. <form action="/addvoorraadact.php" method="POST">
  57.  
  58. <label class= "control-label"><b>Productnaam</b></label>
  59. <input type ="text" class="form-control" placeholder="Schroefdraaier" name="product" required>
  60.  
  61. <label class="control-label"><b>Merk</b></label>
  62. <input type="text" class="form-control" placeholder="Borsch" name="merk" required>
  63.  
  64. <label class="control-label"><b>Aantal</b></label>
  65. <input type="text" class="form-control" name="aantal" required>
  66.  
  67. <label class="control-label"><b>Prijs</b></label>
  68. <input type="text" class="form-control"  name="prijs" required>
  69.  
  70. </p>
  71.  
  72. <label class="control-label"><b>Locatie</b></label>
  73. <select name="locatieselect">
  74. <?php
  75. include_once 'connect.php';
  76.  
  77. $sql = "SELECT * from locatie";
  78. $res = mysqli_query($conn, $sql);
  79.  
  80. while($list = mysqli_fetch_assoc($res)):; ?>
  81.  
  82. <option value="<?php echo $list['lnaam']; ?>"><?php echo $list['lnaam']; ?></option>
  83. <?php endwhile; ?>
  84. </select>
  85. </p>
  86. <button type="submit" class="btn btn-primary" name="submit">Submit</button>
  87. </form>
  88. </div>
  89. </div>
  90. </div>
  91. </div>
  92.  
  93.  
  94. <?php
  95.     include_once 'footer.php';
  96. ?>
  97.  
  98.  
  99. addlocatieact
  100.  
  101. <?php
  102.  
  103.  
  104. if (isset($_POST['submit'])) {
  105.     include_once 'connect.php';
  106.  
  107.     $loca = mysqli_real_escape_string($conn, $_POST['locatienaam']);
  108.     $adre = mysqli_real_escape_string($conn, $_POST['adres']);
  109.     $post = mysqli_real_escape_string($conn, $_POST['postcode']);
  110.     $plaat = mysqli_real_escape_string($conn, $_POST['plaats']);
  111.  
  112.     //Error hanlers
  113.     // Check for empty fields
  114.     if (empty($loca)){
  115.         header("Location: addlocatie.php?naam=leeg");
  116.     } else {
  117.            
  118.             $sql= "INSERT INTO locatie (locatie_id, lnaam, adres, postcode, plaats) VALUES (NULL, '$loca', '$adre', '$post', '$plaat');";
  119.             mysqli_query($conn, $sql);
  120.             header("Location: locatie.php?toevoegen=success");
  121.             exit();
  122.         }
  123.  
  124. } else {
  125.     header("Location: addlocatie.php");
  126.     exit();
  127. }
  128.  
  129.  
  130.  
  131. ?>
  132.  
  133. addvoorraadact.php
  134.  
  135. <?php
  136.  
  137. session_start();
  138.  
  139. if (isset($_POST['submit'])) {
  140.     include_once 'connect.php';
  141.  
  142.     $product = mysqli_real_escape_string($conn, $_POST['product']);
  143.     $merk = mysqli_real_escape_string($conn, $_POST['merk']);
  144.     $aantal = mysqli_real_escape_string($conn, $_POST['aantal']);
  145.     $prijs = mysqli_real_escape_string($conn, $_POST['prijs']);
  146.     $locatie = mysqli_real_escape_string($conn, $_POST['locatieselect']);
  147.  
  148.     //Error hanlers
  149.     // Check for empty fields
  150.             //insert data in de database
  151.         $sql = "SELECT * FROM voorraad WHERE pnaam = '$product'";
  152.         $result = mysqli_query($conn, $sql);
  153.         $resultcheck = mysqli_num_rows($result);
  154.         if($resultcheck >= 1){
  155.             $sql3 = "UPDATE voorraad SET aantal=(aantal + '$aantal'), prijs='$prijs' WHERE pnaam = '$product' AND lnaam='$locatie'";
  156.             mysqli_query($conn, $sql3);
  157.             header("Location: voorraad.php?toevoegen=success");
  158.             exit();
  159.         }else{
  160.             $sql= "INSERT INTO voorraad (voorraad_id, lnaam, pnaam, aantal, prijs, total) VALUES (NULL, '$locatie', '$product', '$aantal', '$prijs', NULL);";      
  161.             mysqli_query($conn, $sql);
  162.             $sql2= "INSERT INTO product (product_id, pnaam, merk, paantal, prijs) VALUES (NULL, '$product', '$merk', '$aantal', '$prijs');";
  163.             mysqli_query($conn, $sql2);
  164.             header("Location: voorraad.php?toevoegen=success");
  165.             exit();
  166.         }
  167.        
  168.  
  169.  
  170. } else {
  171.     header("Location: addvoorraad.php");
  172.     exit();
  173. }
  174.  
  175. ?>
  176.  
  177. connect
  178.  
  179.  
  180. <?php
  181.  
  182. $dbServername ="localhost";
  183. $dbUsername = "root";
  184. $dbPassword="";
  185. $dbName = "tools4ever";
  186.  
  187. $conn = mysqli_connect($dbServername, $dbUsername, $dbPassword, $dbName);
  188.  
  189. ?>
  190.  
  191. footer
  192.  
  193. </body>
  194. </html>
  195.  
  196.  
  197. header
  198.  
  199. <?php
  200.  
  201. session_start();
  202.  
  203. ?>
  204.  
  205.  
  206. <!DOCTYPE html>
  207. <html>
  208. <head>
  209. <title>
  210. </title>
  211. <!-- Latest compiled and minified CSS -->
  212. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
  213.  
  214. <!-- Optional theme -->
  215. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
  216.  
  217. <!-- Latest compiled and minified JavaScript -->
  218. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
  219. </head>
  220.  
  221. <body>
  222.  
  223.  
  224. <nav class="navbar navbar-default">
  225.   <div class="container-fluid">
  226.     <div class="navbar-header">
  227.         <a class="navbar-brand" href="index.php">Home</a>
  228.  
  229.                     <div class="navbar-left">
  230.                         <?php
  231.                             if (isset($_SESSION['u_id'])) {
  232.                                
  233.                                     echo '<ul class="nav navbar-nav">
  234.                                    <li><a href="locatie.php">Locaties</a></li>
  235.                                    <li><a href="addlocatie.php">Locatie toevoegen</a></li>
  236.                                    <li><a href="product.php">Producten</a></li>
  237.                                    <li><a href="voorraad.php">Voorraad</a></li>
  238.                                    <li><a href="addvoorraad.php">Voorraad toevoegen</a></li>
  239.                                    </ul>
  240.                                    <form class="navbar-form navbar-left" action="logout.php" method="POST">
  241.                                    <button type="submit" class="btn btn-danger" name="submit">Logout</button>
  242.                                    </form>';
  243.                            
  244.                                
  245.                             } else {
  246.                                 echo '<form class="navbar-form navbar-left" action="/loginpost.php" method="POST">
  247.                                <div class="form-group">            
  248.                                  <input type="text" class="form-control" placeholder="gebruikersnaam" name="uname" required>
  249.                                  <input type="password" class="form-control" placeholder="wachtwoord" name="upassword" required>
  250.                                 </div>
  251.                                  <button type="submit" class="btn btn-default" name="submit">Login</button>
  252.  
  253.                                    
  254.                                </form>
  255.                                <ul class="nav navbar-nav">
  256.                                    <li><a href="register.php">Registeren</a></li>
  257.                                </ul>';
  258.                             }
  259.  
  260.                         ?>
  261.  
  262.  
  263.                     </div>
  264.         </div>
  265.         </div>
  266. </nav>
  267.  
  268.  
  269. index
  270.  
  271. <?php
  272.     include_once 'header.php';
  273. ?>
  274.  
  275. <section>
  276.     <div class="container">
  277.         <h2>Tools4Ever</h2>
  278.         <?php
  279.         if (isset($_SESSION['u_id'])) {
  280.  
  281.            
  282.                 echo "<h4>Medewerker ".$_SESSION['u_username']. "</h4>";
  283.            
  284.         }
  285.         ?>
  286.     </div>
  287.  
  288. <?php
  289.     include_once 'footer.php';
  290. ?>
  291.  
  292.  
  293. locatie
  294.  
  295. <?php
  296.     include_once 'header.php';
  297. ?>
  298.  
  299. <div class="container">
  300.      <div class="panel panel-warning">
  301.         <div class="panel-heading">Locatie</div>
  302.             <div class="panel-body">
  303. <?php
  304.  
  305. include 'connect.php';
  306.  
  307. $sql = "SELECT * from locatie";
  308. $res = mysqli_query($conn, $sql);
  309. while ($list3 = mysqli_fetch_assoc($res)){
  310.     $locatie = $list3['lnaam'];
  311.     $adres = $list3['adres'];
  312.     $postcode = $list3['postcode'];
  313.     $plaats = $list3['plaats'];
  314. ?>
  315.  
  316.     <ul>
  317.     <b>Plaats:</b><li>  <?php echo $locatie;?></li>
  318.     <b>Straatnaam:</b><li>  <?php echo $adres; ?></li>
  319.     <b>Postcode:</b> <li> <?php echo $postcode; ?></li>
  320.     <b>Plaats:</b> <li> <?php echo $plaats; ?></li>
  321.     </ul></br>
  322.  
  323. <?php
  324. }
  325. ?>
  326.  
  327. </div>
  328. </div>
  329. </div>
  330. </div>
  331.  
  332.  
  333. <?php
  334.     include_once 'footer.php';
  335. ?>
  336.  
  337.  
  338. loginpost
  339.  
  340. <?php
  341.  
  342. session_start();
  343.  
  344. if (isset($_POST['submit'])) {
  345.    
  346.     include 'connect.php';
  347.  
  348.     $usrn = mysqli_real_escape_string($conn, $_POST['uname']);
  349.     $pasw = mysqli_real_escape_string($conn, $_POST['upassword']);
  350.  
  351.     //check if inputs are empty
  352.     if (empty($usrn) || empty($pasw)) {
  353.         header("Location: index.php?login=empty");
  354.         exit();
  355.     } else{
  356.         $sql = "SELECT * FROM users WHERE username = '$usrn'";
  357.         $result = mysqli_query($conn, $sql);
  358.         $resultcheck = mysqli_num_rows($result);
  359.         if ($resultcheck < 1){
  360.             header("Location: index.php?login=error");
  361.             exit();
  362.         } else {
  363.             if ($row = mysqli_fetch_assoc($result)) {
  364.                 //de-hasing wachtwoord
  365.                 $hashedpwdcheck = password_verify($pasw, $row['password']);
  366.                 if ($hashedpwdcheck == false) {
  367.                     header("Location: index.php?login=pwerror");
  368.                     exit();
  369.                 } elseif ($hashedpwdcheck == true) {
  370.                     //Log in the user here
  371.                     $_SESSION['u_id'] = $row['user_id'];
  372.                     $_SESSION['u_username'] = $row['username'];
  373.                     $_SESSION['u_pw'] = $row['password'];
  374.                     $_SESSION['u_name'] = $row['naam'];
  375.                     header("Location: index.php?login=success");
  376.                     exit();
  377.  
  378.                 }
  379.             }
  380.         }
  381.     }
  382. } else {
  383.     header("Location: index.php?login=error");
  384.     exit();
  385. }
  386. ?>
  387.  
  388.  
  389. logout
  390.  
  391. <?php
  392.  
  393.  
  394.  
  395. if (isset($_POST['submit'])) {
  396.     session_start();
  397.     session_unset();
  398.     session_destroy();
  399.     header("Location: index.php");
  400.     exit();
  401. }
  402.  
  403. ?>
  404.  
  405. product
  406.  
  407. <?php
  408.     include_once 'header.php';
  409. ?>
  410.  
  411. <div class="container">
  412.      <div class="panel panel-warning">
  413.         <div class="panel-heading">Producten</div>
  414.             <div class="panel-body">
  415. <?php
  416.  
  417. include 'connect.php';
  418.  
  419. $sql = "SELECT * from product ";
  420. $res = mysqli_query($conn, $sql);
  421.  
  422.  
  423. while ($list = mysqli_fetch_assoc($res)){
  424.    
  425.     $productnaam = $list['pnaam'];
  426.     $merk = $list['merk'];
  427.     $sql2 = "SELECT * FROM voorraad WHERE pnaam='$productnaam'";
  428.     $res2 = mysqli_query($conn, $sql2);
  429.     $list2 = mysqli_fetch_assoc($res2);
  430.     $price = $list2['prijs'];
  431. ?>
  432.  
  433.     <ul>
  434.     <b>Product:</b><li><?php echo $productnaam;?></li>
  435.     <b>Merk:</b><li><?php echo $merk; ?></li>
  436.     <b>Prijs per stuk:</b><li>&euro;<?php echo $price; ?></li>
  437.     </ul></br>
  438. <?php
  439. }
  440. ?>
  441.  
  442. </div>
  443. </div>
  444. </div>
  445. </div>
  446.  
  447.  
  448. <?php
  449.     include_once 'footer.php';
  450. ?>
  451.  
  452.  
  453. register
  454.  
  455. <?php
  456.     include_once 'header.php';
  457. ?>
  458.  
  459.  
  460. <section>
  461.  
  462. <div class="container">
  463.     <form class="form-horizontal" action="/registerpost.php" method="POST">
  464.  
  465.     <div class="panel panel-warning">
  466.         <div class="panel-heading">Registeren</div>
  467.             <div class="panel-body">
  468.                 <label class="col-sm-2 control-label"><b>Gebruikersnaam</b></label>
  469.                 <div class="col-sm-10">
  470.                     <input type="text" class="form-control" placeholder="gebruikersnaam" name="username" required>
  471.                     </br>
  472.                 </div>
  473.                 <label class="col-sm-2 control-label"><b>Wachtwoord</b></label>
  474.                 <div class="col-sm-10">
  475.                     <input type="password" class="form-control" placeholder="wachtwoord" name="password" required>
  476.                     </br>
  477.                 </div>
  478.                 </br>
  479.                 <label class="col-sm-2 control-label"><b>Naam</b></label>
  480.                 <div class="col-sm-10">
  481.                     <input type="text" class="form-control" placeholder="Naam" name="naam" required>
  482.                     </br>
  483.                 </div>
  484.                 <div class="btn-group col-sm-offset-2 col-sm-10" role="group">
  485.                   <button type="button"  class="btn btn-danger" name="cancel">Cancel</button>
  486.                   <button type="submit" class="btn btn-primary" name="submit">Sign Up</button>
  487.                 </div>
  488.             </div>
  489.     </div>
  490.     </form>
  491. </div>
  492. </section>
  493.  
  494. <?php
  495.     include_once 'footer.php';
  496. ?>
  497.  
  498.  
  499. registerpost
  500.  
  501. <?php
  502.  
  503.  
  504. if (isset($_POST['submit'])) {
  505.     include_once 'connect.php';
  506.  
  507.     $usrn = mysqli_real_escape_string($conn, $_POST['username']);
  508.     $pasw = mysqli_real_escape_string($conn, $_POST['password']);
  509.     $name = mysqli_real_escape_string($conn, $_POST['naam']);
  510.  
  511.     //Error hanlers
  512.     // Check for empty fields
  513.     if (!preg_match("/^[a-zA-Z]*$/", $name)){
  514.         header("Location: register.php?signup=invalid");
  515.     } else {
  516.         $sql = "SELECT * FROM users WHERE username='$usrn'";
  517.         $result = mysqli_query($conn, $sql);
  518.         $resultcheck = mysqli_num_rows($result);
  519.  
  520.         if($resultcheck > 0){
  521.             header("Location: register.php?signup=usertaken");
  522.             exit();
  523.         } else {
  524.             //hashing password//
  525.             $hashedpasw = password_hash($pasw, PASSWORD_DEFAULT);
  526.             //insert gebruikerin de database
  527.             $sql= "INSERT INTO users (username, password, naam) VALUES ('$usrn', '$hashedpasw', '$name');";
  528.             mysqli_query($conn, $sql);
  529.             header("Location: register.php?signup=success");
  530.             exit();
  531.         }
  532.     }
  533.  
  534. } else {
  535.     header("Location: register.php");
  536.     exit();
  537. }
  538.  
  539.  
  540.  
  541. ?>
  542.  
  543.  
  544. voorraad
  545.  
  546. <?php
  547.     include_once 'header.php';
  548. ?>
  549.  
  550. <div class="container">
  551.      <div class="panel panel-warning">
  552.         <div class="panel-heading">Voorraad</div>
  553.             <div class="panel-body">
  554. <?php
  555.  
  556. include 'connect.php';
  557.  
  558. $sql = "SELECT * from voorraad ORDER BY lnaam";
  559. $res = mysqli_query($conn, $sql);
  560.  
  561. $sql2 = "SELECT aantal, prijs, (aantal * prijs) as 'total' from voorraad ORDER BY lnaam";
  562. $res2 = mysqli_query($conn, $sql2);
  563.  
  564. while ($list4 = mysqli_fetch_assoc($res)){
  565.     $list5 = mysqli_fetch_assoc($res2);
  566.     $locatie = $list4['lnaam'];
  567.     $product = $list4['pnaam'];
  568.     $aantal = $list4['aantal'];
  569.     $prijs = $list4['prijs'];
  570.     $total = $list5['total'];
  571. ?>
  572.  
  573.     <ul>
  574.     <b>Locatie:</b><li>  <?php echo $locatie;?></li>
  575.     <b>Product:</b><li>  <?php echo $product; ?></li>
  576.     <b>Aantal:</b> <li> <?php echo $aantal; ?></li>
  577.     <b>Prijs per stuk: </b> <li> &euro; <?php echo $prijs; ?></li>
  578.     <b>Totale waarde van deze product: </b> <li> &euro; <?php echo $total; ?></li>
  579.     </ul></br>
  580.  
  581. <?php
  582.  
  583. }
  584. ?>
  585.  
  586. </div>
  587. </div>
  588. </div>
  589. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement