Displaying barcode image in php page?
Posted: Wed Mar 17, 2010 12:55 pm
hi guys. i'm new here...so i apologise if this has come up earlier.
i have a website in php its a for a customers at my hotel. they enter their details and its gets saved to my database on my server (wamp server). Once the data is stored in the database an automatic booking ID is created and assigned to a specific customer.
I have generated a barcode image that carries the customers details (booking ID). my problems is when a customer enters their details on my website, when they finish confirming their booking the barcode image is being saved in a folder. i wanted the image to be displayed on a webpage, but i do not know how to do this....the code is below
Many thanks
page where barcode is being created...it is called the thank you.php page
<?php
session_start();
$_SESSION['firstname']= $_GET['firstname'];
$_SESSION['lastname']= $_GET['lastname'];
$_SESSION['address']= $_GET['address'];
$_SESSION['email']= $_GET['email'];
/*
Mysql query
CREbookingid;ATE TABLE `booking`. (
`bookingid` INT( 10 ) NOT NULL AUTO_INCREMENT,
`firstname` VARCHAR( 100 ) NOT NULL ,
`lastname` VARCHAR( 100 ) NOT NULL ,
`address` VARCHAR( 200 ) NOT NULL ,
`email` VARCHAR( 100 ) NOT NULL ,
`room` VARCHAR( 40 ) NOT NULL ,
`checkin` VARCHAR( 40 ) NOT NULL ,
`checkout` VARCHAR( 40 ) NOT NULL
) ENGINE = MYISAM
ALTER TABLE `booking` CHANGE `bookingid` `bookingid` INT( 10 ) NOT NULL AUTO_INCREMENT
*/
//Store the data in Mysql
$host ="localhost";
$username ="root";
$password ="1234";
$database ="booking table";
$connect = mysql_connect($host, $username, $password) or die ("Connection to Mysql failed");
$selectdb = mysql_select_db($database);
$query = "INSERT INTO booking (firstname, lastname, address, email, room, checkin, checkout) VALUES ( '".$_SESSION['firstname']."','".$_SESSION['lastname']."','".$_SESSION['address']."','".$_SESSION['email']."','".$_SESSION['room']."','".$_SESSION['checkin']."','".$_SESSION['checkout']."')";
$firequery = mysql_query($query) or die ("Query fired Failed");
//Get bookingid
$connect = mysql_connect($host, $username, $password) or die ("Connection 2 to Mysql failed");
$selectdb = mysql_select_db($database);
$query = "select bookingid from booking where email = '".$_SESSION['email']."'";
$firequery = mysql_query($query) or die ("Query 2 fired Failed");
$result = mysql_fetch_array($firequery);
$bookingid = $result['bookingid'];
mysql_close($connect);
require("barcode.inc.php");
$bar= new BARCODE();
if($bar==false)
die($bar->error());
$bar->setSymblogy("UPC-A");
$bar->setHeight(50);
$bar->setFont("arial");
$bar->setScale(2);
$bar->setHexColor("#000000","#FFFFFF");
$barnumber=$bookingid;
$name = "barcode_".$bookingid;
$file= "jpg";
$bar->genBarCode($barnumber,$file,$name);
?>
Page where i want the barcode to be displayed...it is called login_success.php
<?
session_start();
if($_SESSION['myusername'] != ''){
header("location:main_login.php");
}
?>
i have a website in php its a for a customers at my hotel. they enter their details and its gets saved to my database on my server (wamp server). Once the data is stored in the database an automatic booking ID is created and assigned to a specific customer.
I have generated a barcode image that carries the customers details (booking ID). my problems is when a customer enters their details on my website, when they finish confirming their booking the barcode image is being saved in a folder. i wanted the image to be displayed on a webpage, but i do not know how to do this....the code is below
Many thanks
page where barcode is being created...it is called the thank you.php page
<?php
session_start();
$_SESSION['firstname']= $_GET['firstname'];
$_SESSION['lastname']= $_GET['lastname'];
$_SESSION['address']= $_GET['address'];
$_SESSION['email']= $_GET['email'];
/*
Mysql query
CREbookingid;ATE TABLE `booking`. (
`bookingid` INT( 10 ) NOT NULL AUTO_INCREMENT,
`firstname` VARCHAR( 100 ) NOT NULL ,
`lastname` VARCHAR( 100 ) NOT NULL ,
`address` VARCHAR( 200 ) NOT NULL ,
`email` VARCHAR( 100 ) NOT NULL ,
`room` VARCHAR( 40 ) NOT NULL ,
`checkin` VARCHAR( 40 ) NOT NULL ,
`checkout` VARCHAR( 40 ) NOT NULL
) ENGINE = MYISAM
ALTER TABLE `booking` CHANGE `bookingid` `bookingid` INT( 10 ) NOT NULL AUTO_INCREMENT
*/
//Store the data in Mysql
$host ="localhost";
$username ="root";
$password ="1234";
$database ="booking table";
$connect = mysql_connect($host, $username, $password) or die ("Connection to Mysql failed");
$selectdb = mysql_select_db($database);
$query = "INSERT INTO booking (firstname, lastname, address, email, room, checkin, checkout) VALUES ( '".$_SESSION['firstname']."','".$_SESSION['lastname']."','".$_SESSION['address']."','".$_SESSION['email']."','".$_SESSION['room']."','".$_SESSION['checkin']."','".$_SESSION['checkout']."')";
$firequery = mysql_query($query) or die ("Query fired Failed");
//Get bookingid
$connect = mysql_connect($host, $username, $password) or die ("Connection 2 to Mysql failed");
$selectdb = mysql_select_db($database);
$query = "select bookingid from booking where email = '".$_SESSION['email']."'";
$firequery = mysql_query($query) or die ("Query 2 fired Failed");
$result = mysql_fetch_array($firequery);
$bookingid = $result['bookingid'];
mysql_close($connect);
require("barcode.inc.php");
$bar= new BARCODE();
if($bar==false)
die($bar->error());
$bar->setSymblogy("UPC-A");
$bar->setHeight(50);
$bar->setFont("arial");
$bar->setScale(2);
$bar->setHexColor("#000000","#FFFFFF");
$barnumber=$bookingid;
$name = "barcode_".$bookingid;
$file= "jpg";
$bar->genBarCode($barnumber,$file,$name);
?>
Page where i want the barcode to be displayed...it is called login_success.php
<?
session_start();
if($_SESSION['myusername'] != ''){
header("location:main_login.php");
}
?>