Buy Now
Sign in

Generate barcode from field in Thank you message or E-mail

abhishekpatil , March 17 at 13:05
Answered
a
abhishekpatil

Hello Genius,
I am using Chronoforms5 and I want to show a barcode from input field in thank you message. What should I do?
In addition to that, I am using Joomla 3.6.5 and I want to add a field in user details so that I can directly create a barcode without taking details in form everytime. In this case, input data is roll number of student. I want to generate barcode of their roll number on thank you message.

Thank You in advance, Special thanks to GreyHead in Advance.

GreyHead

Hi abhishekpatil ,

You can use PHP in a Custom Code action to create a barcode image. There's an example in this thread using Charles Schefford's barcode.php file - I couldn't find that on-line in a quick search but there's a similar library on GitHub here

Bob

ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much

a
abhishekpatil

Thank you so Much for your quick reply, Thats what I expected from you. I will try it just now. As I am unable to send PM to you now, I will post my reply here.

Thank you.

a
abhishekpatil

Hello GreyHead,
When I tried your solution, I found some following things-
1. It generating barcode on form (in attachment) , I want its code so that I can Show it anywhere like in Email or Thank you message or in PDF.

2. I dont want to generate random id, I just want barcode from input alphanumeric field.

Please do something...

Attachments
barcode.png
barcode.png
(16.13 KiB)
152 Downloads/Views
GreyHead

Hi abhishekpatil ,

You don't need to use the part of the code that creates the random string. Just use the input value from the $form->data array.

Once you have saved the image then you can include that as an image link in an email (remember to use the full URL) or in the thank you message or PDF.

Bob

ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much

a
abhishekpatil

Can't I use it without saving on server?
Is it possible to directly generate in PDF or Thank you message?

GreyHead

Hi abhishekpatil ,

Possibly but I wouldn't try. You could use a cron job to delete any files after say 24 hours if storage is the problem.

Bob

ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much

a
abhishekpatil

If its simple for you to take inputt value from form and generate barcode then will you provide its code please?

Thank you for your continuous guidance.

GreyHead

Hi abhishekpatil,

To echo it out in a Thank you page it would be something like this

				<?php
echo "<img src='".JURI::base()
."components/com_chronoforms5/extras/barcode/barcode.php?barcode="
.$form->data['input_name']."&width=320&height=80' />";
?>
Looking at my old notes that should also work in an email

Bob

PS You can get the barcode.php file here

ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much

a
abhishekpatil

Thank you for the code, I have some doubts,

1) $form->data array is not working in thank you page, something went wrong. I have attached the screenshot.

2)To echo it out in thank you page, which addition should I do in Form code? If its possible, will you provide that?
It should not random code. It should input alphanumeric field from which barcode should be generated in Destination i.e. in Thank you page or Email.

3)How can I save it on server so that I will able to give a link through HTML in Thank you page?

Attachments
Form_data_error.png
Form_data_error.png
(6.36 KiB)
113 Downloads/Views
GreyHead

Hi abhishekpatil,

Sorry, the Thank You page action does not support PHP (I forget that); use a custom Code action instead.

Replace input_name in my example with the name of the input with the value you want to add to the barcode.

Bob

ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much

a
abhishekpatil

Thank you,
Also,
How can I save it on server so that I will able to give a link through HTML in Thank you page?

a
abhishekpatil

Hey I got something..

a
abhishekpatil

From your reply,
I got an idea that,
I can show last message as a custom code instead of 'Show message'.
I got success to show barcode from input.

But there is another problem. I need a print button which will print data.
I have added to it. But when I click on it, barcode dissapears from print. What should I do?

GreyHead

Hi abhishekpatil,

This seems to work OK

				<?php
$path = JPATH_SITE.'/components/com_chronoforms5/uploads/barcodes/';
copy(JURI::base()
."components/com_chronoforms5/extras/barcode/barcode.php?barcode="
.$form->data['input_name']."&width=320&height=80", $path.$form->data['input_name'].'.jpeg');
?>
You may need to change the file name to avoid problems with duplicates.

Bob

ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much

a
abhishekpatil

According to me,
this barcode is not in Image format, it is in form of php code, thats why it diappears on print action. What should I do?

a
abhishekpatil

what will happen if I saved barcode on server and placed its link? Will print function print it?

How can I do that?

How can I save barcode on server? And how to get its link? will you provide its code?

GreyHead

Hi abhishekpatil,

Please check my last post.

Bob

ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much

a
abhishekpatil

Surely your solution works very well, But how to echo it out in custom code? Provided code is just saving img file. How to show it?

a
abhishekpatil

How to echo out it?