In this tutorial we will show you how to generate QR code using PHP and HTML, 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.
You have to download PHP QR Code Library to generate QR code.You may also like generate barcode using PHP.
To Generate QR Code It Takes Only Two Steps:-
- Make a HTML file to send text
- Make a PHP file to generate QR code
Step 1. Make a HTML file to send text
We make a HTML file and save it with a name qrcode.html
<html> <body> <div id="wrapper"> <form method="post" action="generate_code.php"> <input type="text" name="qr_text"> <input type="submit" name="generate_text" value="Generate"> </form> </div> </body> </html>
In this step we create a form to send text entered by the user to storing the text and generating QR code.
Step 2. Make a PHP file to generate QR code
We make a PHP file and save it with a name generate_code.php
<?php if(isset($_POST['generate_text'])) { include('phpqrcode/qrlib.php'); $text=$_POST['qr_text']; $folder="images/"; $file_name="qr.png"; $file_name=$folder.$file_name; QRcode::png($text,$file_name); echo"<img src='images/qr.png'>"; //To Display Code Without Storing QRcode::png($text); } ?>
In this step we get text entered by the user to store in QR code and then we include qrlib.php file which is the main file to generate code then we specify folder in which we were going to store QR code as a image and give a name to that image then we use QRcode::png() predefined function to generate QR code.
That's all, this is how to generate QR code using PHP and HTML. You can customize this code further as per your requirement. And please feel free to give comments on this tutorial.
I hope this tutorial on generate qr code in php helps you and the steps and method mentioned above are easy to follow and implement.
Latest Tutorials
- Create Animated Skill Bar Using jQuery, HTML And CSS
- Simple And Best Responsive Web Design Using CSS Part 2
- Show Button On Hover Using HTML And CSS
- Material Design Login Form Using jQuery And CSS
- Animated Progress Bar Using jQuery And CSS
- Dynamic Drop Down Menu Using jQuery, Ajax, PHP And MySQL
- Get Website Statistics Using PHP, jQuery And MySQL
- HTML5 Login And Signup Form With Animation Using jQuery
- Facebook Style Homepage Design Using HTML And CSS
- View Webpage In Fullscreen Using jQuery