Calico is a Sri Lankan company that manufacture Cords and tapes. Their main customers are Adidas and Nike, company’s manufacturing plant is located at Negombo, Sri Lannka. Recently they approached us to develop a QR-Code generating software for their packing section. Which they can put it on their boxes and access the QR-code using their mobile to get entire details about the package eg: contents, current location and invoice.
We were able to complete this project successfully, within few weeks. To accomplish this task we used technologies such as PHP, Mysql, HTML, CSS and Javascript. For Qr-code generating process, i used a third party library called phpqrcode developed by Alexandre Assouad, you can check his librarys at github-account.
Here is the code snippet for adding phpqrcode library.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
<?php //set it to writable location, a place for temp generated PNG files $PNG_TEMP_DIR = dirname(__FILE__).DIRECTORY_SEPARATOR.'temp'.DIRECTORY_SEPARATOR; //html PNG location prefix $PNG_WEB_DIR = 'temp/'; include "qrlib.php"; //ofcourse we need rights to create temp dir if (!file_exists($PNG_TEMP_DIR)) mkdir($PNG_TEMP_DIR); $filename = $PNG_TEMP_DIR.'test.png'; //processing form input //remember to sanitize user input in real-life solution !!! $errorCorrectionLevel = 'L'; if (isset($_REQUEST['level']) && in_array($_REQUEST['level'], array('L','M','Q','H'))) $errorCorrectionLevel = $_REQUEST['level']; $matrixPointSize = 7; if (isset($_REQUEST['size'])) $matrixPointSize = min(max((int)$_REQUEST['size'], 1), 10); if (isset($_REQUEST['data'])) { //it's very important! if (trim($_REQUEST['data']) == '') die('data cannot be empty! <a href="?">back</a>'); // user data $filename = $PNG_TEMP_DIR.'test'.md5($_REQUEST['data'].'|'.$errorCorrectionLevel.'|'.$matrixPointSize).'.png'; QRcode::png($_REQUEST['data'], $filename, $errorCorrectionLevel, $matrixPointSize, 2); } ?> |
Hope this Helps. 🙂