Join TalkersCode Now !

Get Latest Tutorials And Links On Web Development
And Get Existing Offers Via Email

Generate QR Code Using PHP And HTML

Tuesday, Jan 24, 2017

Tags:- PHP 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.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.You may also like generate barcode using PHP.


Generate QR Code Using PHP And HTML


To Generate QR Code It Takes Only Two Steps:-

  1. Make a HTML file to send text
  2. 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.

Join Us With Our 21000+ Subscribers And Get Our Latest Tutorials Update Via Email

Subscribe TalkersCode! One Of The Best
Web Development And Review Blog

Get Latest Tutorials And Reviews
Via Email