Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- addlocatie
- <?php
- include_once 'header.php';
- ?>
- <div class="container">
- <div class="panel panel-warning">
- <div class="panel-heading">Locatie toevoegen</div>
- <div class="panel-body">
- <form action="/addlocatieact.php" method="POST">
- <label class= "control-label"><b>Naam van locatie</b></label>
- <input type ="text" class="form-control" placeholder="Hoek van Holland afdeling" name="locatienaam" required>
- <label class="control-label"><b>Adres</b></label>
- <input type="text" class="form-control" name="adres" required>
- <label class="control-label"><b>Postcode</b></label>
- <input type="text" class="form-control" name="postcode" required>
- <label class="control-label"><b>Plaats</b></label>
- <input type="text" class="form-control" name="plaats" required>
- </p>
- <button type="submit" class="btn btn-primary" name="submit">Submit</button>
- </p>
- </form>
- </div>
- </div>
- </div>
- </div>
- <?php
- include_once 'footer.php';
- ?>
- addvoorraad
- <?php
- include_once 'header.php';
- ?>
- <div class="container">
- <div class="panel panel-warning">
- <div class="panel-heading">Voorraad toevoegen</div>
- <div class="panel-body">
- <form action="/addvoorraadact.php" method="POST">
- <label class= "control-label"><b>Productnaam</b></label>
- <input type ="text" class="form-control" placeholder="Schroefdraaier" name="product" required>
- <label class="control-label"><b>Merk</b></label>
- <input type="text" class="form-control" placeholder="Borsch" name="merk" required>
- <label class="control-label"><b>Aantal</b></label>
- <input type="text" class="form-control" name="aantal" required>
- <label class="control-label"><b>Prijs</b></label>
- <input type="text" class="form-control" name="prijs" required>
- </p>
- <label class="control-label"><b>Locatie</b></label>
- <select name="locatieselect">
- <?php
- include_once 'connect.php';
- $sql = "SELECT * from locatie";
- $res = mysqli_query($conn, $sql);
- while($list = mysqli_fetch_assoc($res)):; ?>
- <option value="<?php echo $list['lnaam']; ?>"><?php echo $list['lnaam']; ?></option>
- <?php endwhile; ?>
- </select>
- </p>
- <button type="submit" class="btn btn-primary" name="submit">Submit</button>
- </form>
- </div>
- </div>
- </div>
- </div>
- <?php
- include_once 'footer.php';
- ?>
- addlocatieact
- <?php
- if (isset($_POST['submit'])) {
- include_once 'connect.php';
- $loca = mysqli_real_escape_string($conn, $_POST['locatienaam']);
- $adre = mysqli_real_escape_string($conn, $_POST['adres']);
- $post = mysqli_real_escape_string($conn, $_POST['postcode']);
- $plaat = mysqli_real_escape_string($conn, $_POST['plaats']);
- //Error hanlers
- // Check for empty fields
- if (empty($loca)){
- header("Location: addlocatie.php?naam=leeg");
- } else {
- $sql= "INSERT INTO locatie (locatie_id, lnaam, adres, postcode, plaats) VALUES (NULL, '$loca', '$adre', '$post', '$plaat');";
- mysqli_query($conn, $sql);
- header("Location: locatie.php?toevoegen=success");
- exit();
- }
- } else {
- header("Location: addlocatie.php");
- exit();
- }
- ?>
- addvoorraadact.php
- <?php
- session_start();
- if (isset($_POST['submit'])) {
- include_once 'connect.php';
- $product = mysqli_real_escape_string($conn, $_POST['product']);
- $merk = mysqli_real_escape_string($conn, $_POST['merk']);
- $aantal = mysqli_real_escape_string($conn, $_POST['aantal']);
- $prijs = mysqli_real_escape_string($conn, $_POST['prijs']);
- $locatie = mysqli_real_escape_string($conn, $_POST['locatieselect']);
- //Error hanlers
- // Check for empty fields
- //insert data in de database
- $sql = "SELECT * FROM voorraad WHERE pnaam = '$product'";
- $result = mysqli_query($conn, $sql);
- $resultcheck = mysqli_num_rows($result);
- if($resultcheck >= 1){
- $sql3 = "UPDATE voorraad SET aantal=(aantal + '$aantal'), prijs='$prijs' WHERE pnaam = '$product' AND lnaam='$locatie'";
- mysqli_query($conn, $sql3);
- header("Location: voorraad.php?toevoegen=success");
- exit();
- }else{
- $sql= "INSERT INTO voorraad (voorraad_id, lnaam, pnaam, aantal, prijs, total) VALUES (NULL, '$locatie', '$product', '$aantal', '$prijs', NULL);";
- mysqli_query($conn, $sql);
- $sql2= "INSERT INTO product (product_id, pnaam, merk, paantal, prijs) VALUES (NULL, '$product', '$merk', '$aantal', '$prijs');";
- mysqli_query($conn, $sql2);
- header("Location: voorraad.php?toevoegen=success");
- exit();
- }
- } else {
- header("Location: addvoorraad.php");
- exit();
- }
- ?>
- connect
- <?php
- $dbServername ="localhost";
- $dbUsername = "root";
- $dbPassword="";
- $dbName = "tools4ever";
- $conn = mysqli_connect($dbServername, $dbUsername, $dbPassword, $dbName);
- ?>
- footer
- </body>
- </html>
- header
- <?php
- session_start();
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <title>
- </title>
- <!-- Latest compiled and minified CSS -->
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
- <!-- Optional theme -->
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
- <!-- Latest compiled and minified JavaScript -->
- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
- </head>
- <body>
- <nav class="navbar navbar-default">
- <div class="container-fluid">
- <div class="navbar-header">
- <a class="navbar-brand" href="index.php">Home</a>
- <div class="navbar-left">
- <?php
- if (isset($_SESSION['u_id'])) {
- echo '<ul class="nav navbar-nav">
- <li><a href="locatie.php">Locaties</a></li>
- <li><a href="addlocatie.php">Locatie toevoegen</a></li>
- <li><a href="product.php">Producten</a></li>
- <li><a href="voorraad.php">Voorraad</a></li>
- <li><a href="addvoorraad.php">Voorraad toevoegen</a></li>
- </ul>
- <form class="navbar-form navbar-left" action="logout.php" method="POST">
- <button type="submit" class="btn btn-danger" name="submit">Logout</button>
- </form>';
- } else {
- echo '<form class="navbar-form navbar-left" action="/loginpost.php" method="POST">
- <div class="form-group">
- <input type="text" class="form-control" placeholder="gebruikersnaam" name="uname" required>
- <input type="password" class="form-control" placeholder="wachtwoord" name="upassword" required>
- </div>
- <button type="submit" class="btn btn-default" name="submit">Login</button>
- </form>
- <ul class="nav navbar-nav">
- <li><a href="register.php">Registeren</a></li>
- </ul>';
- }
- ?>
- </div>
- </div>
- </div>
- </nav>
- index
- <?php
- include_once 'header.php';
- ?>
- <section>
- <div class="container">
- <h2>Tools4Ever</h2>
- <?php
- if (isset($_SESSION['u_id'])) {
- echo "<h4>Medewerker ".$_SESSION['u_username']. "</h4>";
- }
- ?>
- </div>
- <?php
- include_once 'footer.php';
- ?>
- locatie
- <?php
- include_once 'header.php';
- ?>
- <div class="container">
- <div class="panel panel-warning">
- <div class="panel-heading">Locatie</div>
- <div class="panel-body">
- <?php
- include 'connect.php';
- $sql = "SELECT * from locatie";
- $res = mysqli_query($conn, $sql);
- while ($list3 = mysqli_fetch_assoc($res)){
- $locatie = $list3['lnaam'];
- $adres = $list3['adres'];
- $postcode = $list3['postcode'];
- $plaats = $list3['plaats'];
- ?>
- <ul>
- <b>Plaats:</b><li> <?php echo $locatie;?></li>
- <b>Straatnaam:</b><li> <?php echo $adres; ?></li>
- <b>Postcode:</b> <li> <?php echo $postcode; ?></li>
- <b>Plaats:</b> <li> <?php echo $plaats; ?></li>
- </ul></br>
- <?php
- }
- ?>
- </div>
- </div>
- </div>
- </div>
- <?php
- include_once 'footer.php';
- ?>
- loginpost
- <?php
- session_start();
- if (isset($_POST['submit'])) {
- include 'connect.php';
- $usrn = mysqli_real_escape_string($conn, $_POST['uname']);
- $pasw = mysqli_real_escape_string($conn, $_POST['upassword']);
- //check if inputs are empty
- if (empty($usrn) || empty($pasw)) {
- header("Location: index.php?login=empty");
- exit();
- } else{
- $sql = "SELECT * FROM users WHERE username = '$usrn'";
- $result = mysqli_query($conn, $sql);
- $resultcheck = mysqli_num_rows($result);
- if ($resultcheck < 1){
- header("Location: index.php?login=error");
- exit();
- } else {
- if ($row = mysqli_fetch_assoc($result)) {
- //de-hasing wachtwoord
- $hashedpwdcheck = password_verify($pasw, $row['password']);
- if ($hashedpwdcheck == false) {
- header("Location: index.php?login=pwerror");
- exit();
- } elseif ($hashedpwdcheck == true) {
- //Log in the user here
- $_SESSION['u_id'] = $row['user_id'];
- $_SESSION['u_username'] = $row['username'];
- $_SESSION['u_pw'] = $row['password'];
- $_SESSION['u_name'] = $row['naam'];
- header("Location: index.php?login=success");
- exit();
- }
- }
- }
- }
- } else {
- header("Location: index.php?login=error");
- exit();
- }
- ?>
- logout
- <?php
- if (isset($_POST['submit'])) {
- session_start();
- session_unset();
- session_destroy();
- header("Location: index.php");
- exit();
- }
- ?>
- product
- <?php
- include_once 'header.php';
- ?>
- <div class="container">
- <div class="panel panel-warning">
- <div class="panel-heading">Producten</div>
- <div class="panel-body">
- <?php
- include 'connect.php';
- $sql = "SELECT * from product ";
- $res = mysqli_query($conn, $sql);
- while ($list = mysqli_fetch_assoc($res)){
- $productnaam = $list['pnaam'];
- $merk = $list['merk'];
- $sql2 = "SELECT * FROM voorraad WHERE pnaam='$productnaam'";
- $res2 = mysqli_query($conn, $sql2);
- $list2 = mysqli_fetch_assoc($res2);
- $price = $list2['prijs'];
- ?>
- <ul>
- <b>Product:</b><li><?php echo $productnaam;?></li>
- <b>Merk:</b><li><?php echo $merk; ?></li>
- <b>Prijs per stuk:</b><li>€<?php echo $price; ?></li>
- </ul></br>
- <?php
- }
- ?>
- </div>
- </div>
- </div>
- </div>
- <?php
- include_once 'footer.php';
- ?>
- register
- <?php
- include_once 'header.php';
- ?>
- <section>
- <div class="container">
- <form class="form-horizontal" action="/registerpost.php" method="POST">
- <div class="panel panel-warning">
- <div class="panel-heading">Registeren</div>
- <div class="panel-body">
- <label class="col-sm-2 control-label"><b>Gebruikersnaam</b></label>
- <div class="col-sm-10">
- <input type="text" class="form-control" placeholder="gebruikersnaam" name="username" required>
- </br>
- </div>
- <label class="col-sm-2 control-label"><b>Wachtwoord</b></label>
- <div class="col-sm-10">
- <input type="password" class="form-control" placeholder="wachtwoord" name="password" required>
- </br>
- </div>
- </br>
- <label class="col-sm-2 control-label"><b>Naam</b></label>
- <div class="col-sm-10">
- <input type="text" class="form-control" placeholder="Naam" name="naam" required>
- </br>
- </div>
- <div class="btn-group col-sm-offset-2 col-sm-10" role="group">
- <button type="button" class="btn btn-danger" name="cancel">Cancel</button>
- <button type="submit" class="btn btn-primary" name="submit">Sign Up</button>
- </div>
- </div>
- </div>
- </form>
- </div>
- </section>
- <?php
- include_once 'footer.php';
- ?>
- registerpost
- <?php
- if (isset($_POST['submit'])) {
- include_once 'connect.php';
- $usrn = mysqli_real_escape_string($conn, $_POST['username']);
- $pasw = mysqli_real_escape_string($conn, $_POST['password']);
- $name = mysqli_real_escape_string($conn, $_POST['naam']);
- //Error hanlers
- // Check for empty fields
- if (!preg_match("/^[a-zA-Z]*$/", $name)){
- header("Location: register.php?signup=invalid");
- } else {
- $sql = "SELECT * FROM users WHERE username='$usrn'";
- $result = mysqli_query($conn, $sql);
- $resultcheck = mysqli_num_rows($result);
- if($resultcheck > 0){
- header("Location: register.php?signup=usertaken");
- exit();
- } else {
- //hashing password//
- $hashedpasw = password_hash($pasw, PASSWORD_DEFAULT);
- //insert gebruikerin de database
- $sql= "INSERT INTO users (username, password, naam) VALUES ('$usrn', '$hashedpasw', '$name');";
- mysqli_query($conn, $sql);
- header("Location: register.php?signup=success");
- exit();
- }
- }
- } else {
- header("Location: register.php");
- exit();
- }
- ?>
- voorraad
- <?php
- include_once 'header.php';
- ?>
- <div class="container">
- <div class="panel panel-warning">
- <div class="panel-heading">Voorraad</div>
- <div class="panel-body">
- <?php
- include 'connect.php';
- $sql = "SELECT * from voorraad ORDER BY lnaam";
- $res = mysqli_query($conn, $sql);
- $sql2 = "SELECT aantal, prijs, (aantal * prijs) as 'total' from voorraad ORDER BY lnaam";
- $res2 = mysqli_query($conn, $sql2);
- while ($list4 = mysqli_fetch_assoc($res)){
- $list5 = mysqli_fetch_assoc($res2);
- $locatie = $list4['lnaam'];
- $product = $list4['pnaam'];
- $aantal = $list4['aantal'];
- $prijs = $list4['prijs'];
- $total = $list5['total'];
- ?>
- <ul>
- <b>Locatie:</b><li> <?php echo $locatie;?></li>
- <b>Product:</b><li> <?php echo $product; ?></li>
- <b>Aantal:</b> <li> <?php echo $aantal; ?></li>
- <b>Prijs per stuk: </b> <li> € <?php echo $prijs; ?></li>
- <b>Totale waarde van deze product: </b> <li> € <?php echo $total; ?></li>
- </ul></br>
- <?php
- }
- ?>
- </div>
- </div>
- </div>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement