Dinesh
Dinesh

Reputation: 447

How to set barcode in PHP?

I am creating a website using PHP to get and process the information obtained through a barcode scanner. Is it possible to store the data of patient, so on the registration slip there should be a barcode (containing patient id) for scanner.

I read so much but not sure how to make it dynamically. I read something by a link and implement as:

require("php-barcode.php");

function getvar($name){
    global $_GET, $_POST;
    if (isset($_GET[$name])) return $_GET[$name];
    else if (isset($_POST[$name])) return $_POST[$name];
    else return false;
}

$code=stripslashes(getvar('code'));
if (!$code) $code='123456789012';

$R=barcode_print($code,getvar('encoding'),getvar('scale'),getvar('mode'));

/*
 * call
 * http://........./barcode.php?code=012345678901
 *   or
 * http://........./barcode.php?code=012345678901&encoding=EAN&scale=4&mode=png
 *
 */

?>
<img src="barcode.png" />

Any idea, any suggestion, any link would be much appreciated.

Upvotes: 0

Views: 1606

Answers (1)

Smile
Smile

Reputation: 2758

First thing you need to install Barcode fonts and you can select one of installed fonts to print for code. You can test the output of Barcode from below. (You need to donwload Barcode fonts from this link

<style>
  .barcode{
    font-family:FFontCodePOSTNET;
  }
</style>

and place below in Body tag

<span class="barcode">123</span>

You can see the Barcode output in given image"FFontCode39H3" font used from given download link

Upvotes: 3

Related Questions