QR Code Generator Using PHP
QR code is also known as Quick Response code it is a 2D barcode format code it is used to store text like phone numbers, emails, address and simple text etc.In this tutorial we will show you how to generate QR code using PHP and HTML.You have to download PHP QR Code Library to generate QR code.
Step 1. Make a HTML file and define markup
We make a HTML file and save it with a name barcode.html
In this step we create a form to enter text which is going to be stored in barcode.
Step 2. Make a PHP file to generate barcode
We make a PHP file and save it with a name generate_barcode.php
"; } ?>
To generate barcode you have to download PHP - Barcode library.In this step we get the text entered by user to store in barcode and then we just send the data to barcode.php file which we downloaded to generate barcode and then display the barcode image.For more details of this library functions and query string variable visit there website.
Step 3. Make a CSS file and define styling
We make a CSS file and save it with a name barcode_style.css
body { margin:0 auto; padding:0px; text-align:center; width:100%; font-family: "Myriad Pro","Helvetica Neue",Helvetica,Arial,Sans-Serif; background-color:#F5EEF8; } #wrapper { margin:0 auto; padding:0px; text-align:center; width:995px; } #wrapper h1 { margin-top:50px; font-size:45px; color:#884EA0; } #wrapper h1 p { font-size:18px; } #barcode_div input[type="text"] { width:300px; height:35px; border:none; padding-left:10px; font-size:17px; } #barcode_div input[type="submit"] { background-color:#884EA0; border:none; height:35px; color:white; }
That's all, this is how to generate barcode using PHP and HTML.You can customize this code further as per your requirement. And please feel free to give comments on this tutorial.
Options
Default settings are adjustable inside the file config.php
:
- $_CONFIG = array(
- 'lang' => 'en', // main language
- 'uploads_dir' => 'temp', // uploads directory
- 'qrcodes_dir' => 'qrcodes', // qr codes directory
- 'delete_old_files' => true, // delete periodically old files
- 'file_lifetime' => 24, // delete files older than..(hours) from /uploads_dir and /qrcodes_dir
- 'uploader' => true, // let users upload their own logo
- 'upload_max_filesize' => 1000, // max filesize in Kb
- 'thumb_size' => 130, // size of the squared thumbnail after uploads
- 'qr_bgcolor' => '#FFFFFF', // default background color for generated qrcodes
- 'qr_color' => '#000000', // default foreground color for generated qrcodes
- 'session_name' => 'qrSession', // custom session name for the script
- 'placeholder' => 'images/placeholder.png', // default placeholder
- 'link' => true, // activate link tab
- 'location' => true, // activate location tab
- 'email' => true, // activate email tab
- 'text' => true, // activate text tab
- 'tel' => true, // activate telephone tab
- 'sms' => true, // activate sms tab
- 'wifi' => true, // activate wifi tab
- 'vcard' => true, // activate v-card tab
- 'paypal' => true, // activate PayPal tab
- 'bitcoin' => true, // activate BitCoin tab
- 'whatsapp' => true, // activate WhatsApp tab
- 'default_tab' => '#link', // available options: #link | #location | #email | #text | #sms | #wifi | #vcard | #paypal | #bitcoin | #whatsapp
- 'detect_browser_lang' => false, // detect browser language
- 'google_api_key' => 'YOUR-API-KEY', // https://developers.google.com/maps/documentation/javascript/get-api-key#get-an-api-key
- 'color_primary' => false, // main color, used for buttons and header background. set a #hex color or false to get random colors
- );
Watermarks
If you want to change or hide default watermarks, simply replace or remove the images inside images/watermarks/
.jpg, .gif, .png file are accepted
Location
Google Map needs an API KEY, so if you enable the tab Location you must get one api key here:
https://developers.google.com/maps/documentation/javascript/get-api-key#get-an-api-key
and copy it inside the file config.php
If you want to change the default location shown by Google map, open js/all.js
, around line 39.
var start = new google.maps.LatLng(40.7127837, -74.00594130000002);
Customization
The attribute 'color_primary'
inside the file config.php will set the main color for all the buttons and on the header background.
Since version 3.0 you have two starter templates called header.php and footer.php, located inside the folder /template/
Edit their contents or remove them if you don't need that
Manage translations
If you want to add your custom language, duplicate and rename the file lang/en.php
using the 2-letters ISO code desired and update also the value 'lang' => 'en'
inside your main config file config.php
Language menu is displayed with the following function:
you can choose if display it as dropdown menu (default) or as simple list, and set a custom class:
The first variable can be 'menu' or 'list', the second is an optional custom class assigned to language menu (default: 'langmenu')
All translatable terms, including page title, description, and meta-keywords are inside the respective .php file in /translations/ folder.
default: /translations/en.php
Embed
You can embed your self hosted generator everywhere using iframes:
click here and Use the QRCode Generator Tool Fully Free :
Notes
Print media styles, Typography, Forms and Tables are based on Bootstrap v4
Icons are based on Font Awesome 4.7