Php barcode generator code 128

PHP Barcode Generator Script Overview

This barcode generation product is a server-side PHP script that generates streaming barcodes to the requesting web browser. It is compatible with any operating system, web server, and hosting provider that supports PHP scripts including IIS, Apache, WordPress, and Zend. After the script file is copied to the web server, PHP barcode images are generated on the server in memory and streamed to the client without saving any temp files on the server.

User Manual Download Demo

Each barcode type is provided as a single unencrypted PHP file, which provides extremely fast barcode generation with very little overhead. Each PHP barcode script file is provided in pure PHP source code form, so it may be used natively and customized or integrated within any web application. The PHP barcode images generated are simple black and white bit-mapped BMP images (1bpp) and are very small in size compared to JPEG or GIF images; the average generated barcode size is usually less than 2KB.

The following source code example demonstrates a simple method used to create dynamic barcodes within a PHP script:

<html><body>
<p>This web page uses PHP code to create a barcode.</p>
<?php
$BarcodeData = "123456789012";
?>
<p><img src="idautomation-code128.php?Barcode=<?=$BarcodeData;?>"></p>
</body></html>
PHP Barcode Generator Script Compatibility and Requirements
Application Compatibility Any web server or website hosting service that supports PHP script processing.
Minimum System Requirements 300 MHZ Processor, 256 MB RAM, 5 MB available hard drive space.
Intended Implementer Web designers and developers.
Linear Symbology Compatibility Code 39, Code 128 (with character sets A, B and C), GS1-128, QR Code, Micro QR-Code, GS1-QRCode, Data Matrix ECC-200, GS1-DataMatrix, Interleaved 2 of 5, MSI, ITF, USPS Postnet and Planet.

Barcode is a machine readable code which generated using items details like item name, item code, price etc. The related Barcode is tagged on item to get item details using Barcode reader machine. The Barcode is very useful for fast selling items to identify items quickly and also useful to manage inventory to prevent inventory build-up for slow selling items. As the Barcode is very useful and needed to implement in many PHP projects to manage inventories etc, so in this tutorial you will learn how to implement Barcode generator using PHP. We will cover this tutorial with live demo to create Barcode generator with PHP.

Also, read:

  • Build Invoice System with PHP & MySQL
  • Build Live Chat System with Ajax, PHP & MySQL
  • Build Comment System with Ajax, PHP & MySQL

As we will cover this tutorial with live demo to implement Barcode generator using PHP, so the file structure for this example is following.

  • index.php
  • barcode.php

Step1: Create Barcode Generate Form
First in index.php, we will create Barcode generate HTML Form to create Barcode on form submit with options.

	<div class="row">
<div class="col-md-4">
<form method="post">
<div class="row">
<div class="col-md-8">
<div class="form-group">
<label>Product Name or Number</label>
<input type="text" name="barcodeText" class="form-control" value="<?php echo @$_POST['barcodeText'];?>">
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>Barcode Type</label>
<select name="barcodeType" id="barcodeType" class="form-control">
<option value="codabar" <?php echo (@$_POST['barcodeType'] == 'codabar' ? 'selected="selected"' : ''); ?>>Codabar</option>
<option value="code128" <?php echo (@$_POST['barcodeType'] == 'code128' ? 'selected="selected"' : ''); ?>>Code128</option>
<option value="code39" <?php echo (@$_POST['barcodeType'] == 'code39' ? 'selected="selected"' : ''); ?>>Code39</option>
</select>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>Barcode Display</label>
<select name="barcodeDisplay" class="form-control" required>
<option value="horizontal" <?php echo (@$_POST['barcodeDisplay'] == 'horizontal' ? 'selected="selected"' : ''); ?>>Horizontal</option>
<option value="vertical" <?php echo (@$_POST['barcodeDisplay'] == 'vertical' ? 'selected="selected"' : ''); ?>>Vertical</option>
</select>
</div>
</div>
</div>
<div class="row">
<div class="col-md-7">
<input type="hidden" name="barcodeSize" id="barcodeSize" value="20">
<input type="hidden" name="printText" id="printText" value="true">
<input type="submit" name="generateBarcode" class="btn btn-success form-control" value="Generate Barcode">
</div>
</div>
</form>
</div>
</div>

Step2: Get Barcode Generator Library
We need to download Barcode generate PHP library to create Barcode . In this example we have already downloaded barcode.php and used to create Barcode. The library has
options to create Barcode with type Codabar, Code128, Code39 and Barcode display type Horizontal and Vertical. It also supports options for size (10, 20 and 400 maximum) and option to display Barcode with text. So we will handle all these options in this example.

Step3: Generate Barcode with PHP
Now on Form submit, we will generate Barcode by passing items details to library file barcode.php and display created Barcode in img.

<?php
if(isset($_POST['generateBarcode'])) {
$barcodeText = trim($_POST['barcodeText']);
$barcodeType=$_POST['barcodeType'];
$barcodeDisplay=$_POST['barcodeDisplay'];
$barcodeSize=$_POST['barcodeSize'];
$printText=$_POST['printText'];
if($barcodeText != '') {
echo '<h4>Barcode:</h4>';
echo '<img class="barcode" alt="'.$barcodeText.'" src="barcode.php?text='.$barcodeText.'&codetype='.$barcodeType.'&orientation='.$barcodeDisplay.
'&size='.$barcodeSize.'&print='.$printText.'"/>';
} else {
echo '<div class="alert alert-danger">Enter product name or number to generate barcode!</div>';
}
}
?>

You may also like:

  • Star Rating System with Ajax, PHP and MySQL
  • Create Event Calendar with jQuery, PHP and MySQL
  • Build Your Own CAPTCHA Script with PHP
  • Convert Unix Timestamp To Readable Date Time in PHP
  • Inventory Management System with Ajax, PHP & MySQL
  • Create Live Editable Table with jQuery, PHP and MySQL
  • Live Add Edit Delete datatables Records with Ajax, PHP and MySQL
  • Stripe Payment Gateway Integration in PHP
  • Export Data to Excel with PHP and MySQL
  • Star Rating System with Ajax, PHP and MySQL
  • Create Dynamic Bootstrap Tabs with PHP & MySQL
  • How To Create Simple REST API in PHP

You can view the live demo from the Demo link and can download the script from the Download link below.
Demo Download

How do I get a barcode Code 128?

The best way to create a barcode Code 128 is to use a professional code 128 generator. The Code 128 is a linear bar code symbology capable of encoding the full 128-character ASCII character set and extended character sets..
OnBarcode..
Raco Industries..
Barcoding..

How many numbers are in a Code 128 barcode?

Code 128 includes 108 symbols: 103 data symbols, 3 start symbols, and 2 stop symbols. Each symbol consists of three black bars and three white spaces of varying widths.

Is Code 128 a 1D barcode?

Code 128 barcodes are one-dimensional ("1D") bar code symbols used throughout the ID, inventory, shipping and distribution chain. The Code 128 character set has both numbers and letters, punctuation marks, and control codes. They can be printed with or without human-readable characters above or below the bars.