How to Generate Barcode Using PHP

This PHP Barcode Generator is a server-side PHP script that generates and displays dynamic barcode data that can be integrated into any web application. PHP barcodes generate very small images about 2KB, miniscule in comparison to the size of standard JPG or GIF barcode images. You may also like How to Generate QR Code Using PHP And HTML.

To generate barcode you have to download PHP – Barcode library.

HTML Code

<html>
    <body>
        <form method="post" action="">
            <input type="text" name="barcode_text">
            <input type="submit" name="generate_barcode" value="GENERATE">
        </form>
    </body>
</html>

PHP Code

<?php
if(isset($_POST['generate_barcode']))
{
    $text=$_POST['barcode_text'];
    echo "<img alt='testing' src='barcode/barcode.php?codetype=Code39&size=40&text=".$text."&print=true'/>";
}
?>

Leave a Reply

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