Forums

Insert qr code in a database

jsole125 17 Jul, 2016
Hello,

I would like to have some registers of a Chronoform added into a qr code and saved in a database when the submit button is pressed. I have found this entry:
https://www.chronoengine.com/faqs/70-cfv5/5271-creating-a-qr-code-from-form-data.html
I have not tried it yet because I have no idea of how get it saved into the database. Is there a simple way to get it to work?

Thanks in advance
GreyHead 17 Jul, 2016
Hi jsole125,

You can save an image in a database table - see this StackOverFlow answer for example. But, like the person who answered there, I don't recommend it. Better to save the image to a folder and save the image file name and location to the database table.

Bob
jsole125 17 Jul, 2016
Hi Bob,

Thank you for your quick answer.

I tried what you have said with no success.

Once "extras" folder was created, and had been pasted there the "qr code generator" (phpqrcode.php) and cache folders, as mentioned in the link that I put in the first message. I have changed the php script to accomplish the requirements of my system and I gave it a try just in case it worked.

Unfortunately, the following message pops up:

Forbidden
You do not have permission to access this document.

Web Server at ecomercaderet.cat



The folders have 755 permissions and files 644.
Any idea would be appreciate

Thank you
GreyHead 18 Jul, 2016
Hi jsole125,

There isn't enough information here to say anything much except that there is a permissions problem somewhere. Have you any idea where in the code this message is generated? If you enable site Debugging you might see some more useful messages.

Do you have FTP enabled on the site? That can sometimes give rise to permissions problems?

Bob
jsole125 18 Jul, 2016
Hi Bob,

I decided start again. I made a Chronoform which is properly working. DB saving is ok.
Now I know it is better to save the qr code in a folder and to save the name and location to the DB. So that is what I want achieve.
Should I use the script in this page in order to save name and location?
https://www.chronoengine.com/faqs/70-cfv5/5271-creating-a-%3Cspan
Or should I use other?

Thanks
GreyHead 18 Jul, 2016
Hi jsole125,

I suggest that you try that one.

Bob
jsole125 18 Jul, 2016
Hi Bob,

Thank you for your advice.
It has come to my mind that I already have an image which is saved in a folder and name and location in the DB. Could this be the problem?

Thanks
GreyHead 18 Jul, 2016
Hi jsole125,

Sorry, there is no way I can tell if that is the problem . . . I don't even know what the problem is :-(

Bob
jsole125 18 Jul, 2016
Hi Bob,

// this line sets the content of the qr code
$text = $form->data['text1'];

I have changed "text1" for the "field name" of the design item that I want to get it in the qr code. Is that right?

Josep
GreyHead 18 Jul, 2016
H Josep,

Yes, that's correct.

Bob
jsole125 18 Jul, 2016
Hello again Bob,

As the rest of the script (previous message) I think it is ok, I paste it in a On Submit event from Basic Custom Code. When I click on save I get the following error message:

Forbidden
You do not have permission to access this document.

Permissions:
phpqrcode.php 644
uploads/qrcodes/ 755

Where could be the error?

PS This instance of Joomla has not enabled the FTP layer.

Josep
GreyHead 19 Jul, 2016
Hi Josep,

Please take a Form Backup using the icon in the Forms Manager and post it here (as a zipped file) or PM or email it to me and I'll take a closer look on my test server.

I suspect that this is a server permissions problem - you may need to check with your web host.

Bob
jsole125 19 Jul, 2016
Hello Bob,

Here you are. The specific form is called "entrallavors".

I could not put the script into the custom code item because of the error. So I have attached an other php file with the script as I put it in the event box.

Thanks again
GreyHead 20 Jul, 2016
Hi jsole125,

I restored your form on my test site here and it is working correctly.

The only problem I can see is that the path in the Files Upload action images/joodb/entrallavors/ may not be correct, this needs to be an absolute path including the folders above the site root. Check the qr_code path in the Debugger output to see an example.

Bob
jsole125 20 Jul, 2016
Hi Bob,

No success. I have got the same error.

I have even changed this:
$folder = JPATH_SITE.'/components/com_chronoforms5/uploads/qrcodes/';

into the absolute path to my site:
/httpdocs/components/com_chronoforms5/uploads/qrcodes

with no luck.

Images work either absolute path or the one I had before.

What looks strange to me is that while images can be upload with no problems on permissions, qr codes can not.

Thanks

Josep
GreyHead 20 Jul, 2016
Hi Josep,

By all means PM me the site URL, the form name, and a SuperAdmin login and I'll take a quick look. I'm not sure that I'll find anything though, this may need your web host to take a look.

Bob
GreyHead 21 Jul, 2016
Hi Josep,

Please check with your web host - as far as I can see there is some security setting in your site that prevents you saving PHP from form actions.

Bob
jsole125 22 Jul, 2016
Hi Bob,

I have been in contact with my web host service and they told me, as you have said, that it is a question of security. As it is a shared web hosting, "the injection of code in database is not allowed" in order not to compromise server security (?).

Puzzled. Any workaround?

Thank you

Josep
GreyHead 23 Jul, 2016
Hi Josep,

That would explain it; I'm afraid that the only suggestion that I have is to change your web host :-(

Bob
This topic is locked and no more replies can be posted.