Forums

[SOLVED] Database failures

Gekko23 09 Jan, 2009
Hi once again!

I'm just before presenting my work to my customer, so i will be YOUR customer for a ChronoForms license soon! :-)

But until then, there are these two issues i can't solve myself:

1)i use ChronoForms to let it send documents to an entered email adress. i read out the itemid from where the user entered the download page and hand it over by a hidden input field. after sending, the engine redirects to the previous content page and i'm able to give a success message for the user informing that the document has been successfully sent.
all of this is working like a charm. but unfortunately no database record gets created.

I discoverd the origin of this...inside my ChronoForms form in the "form code" tab, i entered the following code in the "On Submit code - after sending email" field:

$id = JRequest::getVar('Path');
$mainframe->redirect(JRoute::_($id),"Thank you for your interest. The document has been sent to your email adress.<br />");

i think the page gets redirected BEFORE it is assumed to put the record into the database. If i remove the redirect, a record gets created.
How can i use this code and have the database entry recorded, too?

2)
When exporting records from that site to excel format, there's just one cell entry in it with the following message:
<b>Warning</b>:  tempnam() [<a href='function.tempnam'>function.tempnam</a>]: open_basedir restriction in effect. File() is not within the allowed path(s): (/var/www/html/xyz:/tmp) in <b>/var/www/html/xyz/html/158/administrator/components/com_chronocontact/excelwriter/PPS/File.php</b> on line <b>87</b><br />

(xyz is changed by me for publishing it here)
What does this mean and how can i solve this?

Thanks for your help,
Gekko =)
GreyHead 09 Jan, 2009
Hi Gekko23,

There are options in ChronoForms v3.0 to run the OnSubmit After code *after* the AutoGenerated code. This might help. Otherwise you can use the ChronoForms redirect
<?php
global $mainframe;
$mainframe->enqueuemessage('Thank you for your interest. The document has been sent to your email adress.');
$rows[0]->redirecturl = JRequest::getVar('Path');
?>
This will execute after the AutoGenerated code by default.

The Excel problem is because you don't have the necessary permissions to write the temporary folder. open_basedir is a PHP security setup (which causes quite a few problems like this). Contact your ISP to see what needs to be done.

Bob
Gekko23 10 Jan, 2009
Great!
Your code works!

Btw...is there any good tutorial/posting here, which explains the format/naming of variables & arrays that ChronoForms accepts for processing and especially for being able to put them into the database?
I don't understand how to get custom variables into the database such as any $xyz...e.g. when creating the table-record-overview-format, i'm able to put in some custom named columns, but how can i get these custom columns filled with data, that comes out of PHP code and not out of any form field?

I'm very unsure now because i didn't have a clue that anything like

$rows[0]->redirecturl

does exist.
Or that

$attachments['file1']

produces an attachment.

i want to inject some variable data with every record CF makes, but they aren't form field data and i would like to know how to name them or which array (name) has to be used to hand over their data.

Thank you soo much for your help
and once again thank you for providing the solution for my initial question!

Greetz,
Gekko =)
GreyHead 10 Jan, 2009
Hi Gekko,

Great, I'm glad the code works for you.

And I'm sorry there is no detailed manual. The forums here and asking questions are the best way to find out. Max knows the code because he writes it. I know the ChronoForms code because I've spent a long time inside it working out what makes it tick and how to get it to jump through a few hoops. (I don't know ChronoConnectivity or ChronoComments nearly as well.)

For those specific variables - $rows is where ChronoForms keeps the working copy of the form parameters (the info from the form tabs); $attachments is the email atttachment array where it builds the info about file uploads. While i remember some of this I often dive into the code to check, it doesn't take long as I know pretty much where to look.

There are several ways to put your own variables into ChronoForms outputs. The simplest is to add a hidden field to your form with the name that you want to use but with no value. The hidden field will work OK with the Create Table command and the email templates, and you can use PHP in the OnSubmit boxes to set the value.

The last thing here is that DeBug code is your friend. I frequently add in a line of code to echo info about a variable to the screen so that I can see what is happening, or just what 's in it. I even have a little home-made plugin that logs code to a file so that I can dump whole Joomla objects without messing up the display.

I hope that helps a bit.
Gekko23 10 Jan, 2009
Once more:
I've never had the pleasure of witnessing such a fast and competent team...i'm absolutely serious.
Unfortunately, i already DID a fivestar review on Joomla.org, the last thing to do is to buy your extension.

Thank you ...how many times i wrote this in here? =)... so much for your fast help...i will try to figure it out, but your reply helps a LOT!
Thanks again,

Gekko =)
This topic is locked and no more replies can be posted.