Multiple Barcode Generator in PHP, in this coding article we create a Barcode generator which you can use for your invoicing system for E-Commerce websites.
Barcode: Barcode is a machine-readable code, it can be horizontal or vertical in shape. Barcode contains information about your product SKU, price, manufacturing date, and expiry date.
For creating Barcode Generator we use Barcode Library and some of our own PHP code.
Properties of Barcode
Different format Of Barcode
- Codabar
- Code39
- Code25
- Code128 (Default)
Different orientation for display Barcode
- Horizontal (Default)
- Vertical
Different size for Barcode
- 10
- 20 (Default)
- 400
Barcode Generator Library
I included the same library file on the below complete source code download link.
Library URL: https://github.com/davidscotttufts/php-barcode/
3 Steps to Creating Barcode Generator using PHP
Here are 3 steps to How to create Barcode Generator using PHP,
- Create some HTML text box for user input.
- Include PHP Barcode Library.
- Create PHP file which generate Barcode (Image Type).
Step-1
barcode.html
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
<html> <head> <title>Generate Barcode Using PHP</title> </head> <body> <h2>Generate Barcode Using PHP</h2> <form method="post" action="generate_barcode.php"> Name:<br> <input type="text" name="barcode_text"><br><br> Mfg. Date:<br> <input type="date" name="mfgDate"> <br><br> <input type="submit" name="generate_barcode" value="GENERATE"> </form> </body> </html> |
Step-2
Include barcode library, barcode.php
https://github.com/davidscotttufts/php-barcode/blob/master/barcode.php
Step-3
generate_barcode.php
1 2 3 4 5 6 7 8 9 10 |
<?php if(isset($_POST['generate_barcode'])) { $text = $_POST['barcode_text']; $mfgdate = $_POST['mfgDate']; echo "Name: <img alt='".$text."' src='barcode.php?codetype=Code39&size=20&text=".$text."&print=true'/>"; echo "<br>"; echo "Mfg Date: <img alt='".$mfgdate."' src='barcode.php?codetype=Code39&size=20&text=".$mfgdate."&print=true'/>"; } ?> |
Here are some important parameters which we use to modify the design of the Barcode.
Parameters:
- Text: “0” (Default)
- Size: “20” (Default)
- Code Type: “Code128” (Default)
- Orientation: “Horizontal” (Default)
Here is the output:
Here is the complete working Source code of Multiple Barcode Generator Using PHP.
[sociallocker]Download Complete File: Click Here[/sociallocker]
Also Check:
- Concept of CSS Grid Layout
- CSS background-image Properties
- Login with Google Account using PHP Step by Step
- Display Current Date and Time in HTML using JavaScript
2 Replies to “Multiple Barcode Generator in PHP”