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.

QR Code Generator Using PHP

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:

  1. $_CONFIG = array(
  2. 'lang' => 'en', // main language
  3. 'uploads_dir' => 'temp', // uploads directory
  4. 'qrcodes_dir' => 'qrcodes', // qr codes directory
  5. 'delete_old_files' => true, // delete periodically old files
  6. 'file_lifetime' => 24, // delete files older than..(hours) from /uploads_dir and /qrcodes_dir
  7. 'uploader' => true, // let users upload their own logo
  8. 'upload_max_filesize' => 1000, // max filesize in Kb
  9. 'thumb_size' => 130, // size of the squared thumbnail after uploads
  10. 'qr_bgcolor' => '#FFFFFF', // default background color for generated qrcodes
  11. 'qr_color' => '#000000', // default foreground color for generated qrcodes
  12. 'session_name' => 'qrSession', // custom session name for the script
  13. 'placeholder' => 'images/placeholder.png', // default placeholder
  14. 'link' => true, // activate link tab
  15. 'location' => true, // activate location tab
  16. 'email' => true, // activate email tab
  17. 'text' => true, // activate text tab
  18. 'tel' => true, // activate telephone tab
  19. 'sms' => true, // activate sms tab
  20. 'wifi' => true, // activate wifi tab
  21. 'vcard' => true, // activate v-card tab
  22. 'paypal' => true, // activate PayPal tab
  23. 'bitcoin' => true, // activate BitCoin tab
  24. 'whatsapp' => true, // activate WhatsApp tab
  25. 'default_tab' => '#link', // available options: #link | #location | #email | #text | #sms | #wifi | #vcard | #paypal | #bitcoin | #whatsapp
  26. 'detect_browser_lang' => false, // detect browser language
  27. 'google_api_key' => 'YOUR-API-KEY', // https://developers.google.com/maps/documentation/javascript/get-api-key#get-an-api-key
  28. 'color_primary' => false, // main color, used for buttons and header background. set a #hex color or false to get random colors
  29. );

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