Index File
Of course, the index file is pretty simple. We just include the header, menu and footer files.
<?php include_once('header.php');?> <?php include_once('menu.php');?> <h1>Inventory</h1> <p>Create account to keep track of your home inventory</p> <?php include_once('footer.php'); ?>
Sign-up Script
Well, the first thing everyone sees on an app is a sign up page. We made this nice and easy and used a little bit of AJAX to process the script.
<?php include_once('header.php');?> <?php include_once('menu.php');?> <h1>Inventory Signup Page</h1> <form> <div class="form-group"> <label for="name">Name:</label> <input id="name" class="form-control" type="text" placeholder="Name"> <label for="email">Email:</label> <input id="email" class="form-control" type="email" placeholder="Email"> <label for="password">Password:</label> <input id="pass" class="form-control" type="password" placeholder="Password"> <label for="spam">Spam Control: Type Yes in the box below</label> <input id="spam" class="form-control" type="text" placeholder="Yes"> <button type="submit" id="submit" class="btn btn-default">Submit</button> </div> </form> <div id="display"></div> <script> $(document).ready(function(){ $("#submit").click(function(){ var name = $("#name").val(); var email = $("#email").val(); var pass = $("#pass").val() var spam = $("#spam").val() var dataString = 'name1='+ name + '&email1='+ email+ '&pass1='+ pass+'&spam1='+ spam; if(name==''||email==''||pass==''||spam=='') { $("#display").html("Please Fill All Fields"); } else { $.ajax({ type: "POST", url: "processor.php", data: dataString, cache: false, success: function(result){ $("#display").html(result); } }); } return false; }); }); </script> <?php include_once('footer.php'); ?>
Processor File
Here is where we process the sign ups. We enter all the data into the database, filter and sanitize it all. We also use PASSWORD_BCRYPT to create the password. Then we echo it all back to the user via AJAX. 🙂
<?php include_once('config.php'); $name = filter_var($_POST['name1'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH); $email = filter_var($_POST['email1'], FILTER_SANITIZE_EMAIL, FILTER_FLAG_STRIP_HIGH); $pass = filter_var($_POST['pass1'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH); $spam = filter_var($_POST['spam1'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH); if($spam == 'Yes'){ $hash=password_hash($pass, PASSWORD_BCRYPT); mysqli_query($con,"INSERT INTO users(`name`, `email`, `password`)VALUES('$name','$email','$hash')"); echo '<strong>'.$name.'</strong><br/>'; echo '<strong>'.$email.'</strong><br/>'; echo 'This is the password:<strong>'.$pass.'</strong><br/>'; echo 'This is the encrypted password: <strong>'.$hash.'</strong><br/>'; $con->close(); }else{ echo '<div class="alert alert-danger">You need to type Yes in the spam box.</div>'; die(); } ?>
The Zip File
I have to tell you that this would be an awfully long article so I am just going to give you all the scripts. You can go over them all and contact me if you have questions. Watch the programming video for this is you like, it is very long. Here is the zip file.
8 Comments
Hey, very nice app. I can see that your online version is updated a lot since the first version. Is there any chance of getting do download the updated php files for the updates you have done to the inventory app?
HI Morton, thanks. Yes I still have a little more I want to get done then I am going to make another post with the updated files. If you subscribe you will be notified with I do! 🙂 Thanks!
Hi Maximus, i have been thinking about this app for the last week, and i have several improvements i would like to propose to you for this app. But i would really like to get my hand on the source files for your latest updated version of the app before i can start suggesting new functions and so on. And i would really like to be able to do some testing on my local installation before i send you any suggestions. So as you can see i am waiting to get my local installation upgraded to your latest version to be able to go forward with using and sending you questions about new features and so on 🙂 I hope i may get my hands on the latest source files sooner than later to be able to move forward 🙂 Kind regards, Morten
Sure thing, Ill work on that today. I just have to get my private API stuff out of there. I have not forgotten about it, just been real busy on things lately, lol
Here is the file you have been waiting for. Password is my first name, all lowercase. 🙂 Enjoy
I added a category field in the merch table and I believe I have edited all of the relevant files to take that field into consideration. Have you thought about adding a category field to the online application?
Yes I added it to the location or category in addition I added “tags” to the “bins” because they both function in the same way as a category.
OK, I see…the online application is set up so that you can enter a location or category in the location field. I just entered a separate field for the category so that there is a location and category field. As for the tags, I have to read up some more about them, as I am not sure how they really work.