How to Generate QR Code Using PHP And HTML

QR (Quick Response) code used to read your data in your smart devices for ease. If you have a visiting card and want to add name, email and mobile number in you mobile its hart to type if there is a QR code of contact added on that card then you can easily add that in you contact list by scanning that code. Today i am going to show you how to generate a QR code in PHP.

HTML Code

<html>
    <body>
        <div id="wrapper">
            <form method="post" action="">
               <input type="text" name="qr_text">
               <input type="submit" name="generate_text" value="Generate">
            </form>
        </div>
    </body>
</html>

PHP Code

<?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'>";
}
?>

Leave a Reply

Your email address will not be published. Required fields are marked *