Forums

form using table doesn't save.

farscape 03 Sep, 2008
Hi. Newbie here. I just installed the latest Chrono forms component and mambot on a Joomla 1.5 site. I set up a simple form w/no validation, to save data to a table. The form processes fine from the user point of view, but when I try to "Show Saved Data", there's nothing there. My form code and auto-generated code follow. Any suggestions appreciated!

Form code:

<p> </p><p>We're looking for input into the songs we sing in Sunday services. We want to know your five favorite Christian songs. It doesn't matter whether it's a traditional hymn or contemporary song, gregorian chant or church camp ditty. </p><p>  </p><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="floatbox"><table width="50%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="10%" valign="top"><strong>Song 1 </strong></td>
<td width="25%" valign="top"><input name="Song1" type="text" id="Song1" size="30"></td>
</tr>
<tr>
<td valign="top"><strong>Song 2 </strong></td>
<td valign="top"><input name="Song2" type="text" id="song2" size="30"></td>
</tr>
<tr>
<td valign="top"><strong>Song 3 </strong></td>
<td valign="top"><input name="Song3" type="text" id="Song3" size="30"></td>
</tr>
<tr>
<td valign="top"><strong>Song 4 </strong></td>
<td valign="top"><input name="Song4" type="text" id="Song4" size="30"></td>
</tr>
<tr>
<td valign="top"><strong>Song 5 </strong></td>
<td valign="top"><input name="Song5" type="text" id="Song5" size="30"></td>
</tr>
</table></td>
</tr>
</table>
<p> </p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>

The auto-generated code:

<?php
$database =& JFactory::getDBO();
srand((double)microtime()*10000);
$inum = "I" . substr(base64_encode(md5(rand())), 0, 16);

$database->setQuery( "INSERT INTO #__chronoforms_2 VALUES (
'' , '".$inum."','". date('Y-m-d')." - ".date("H:i:s")."', '".$_SERVER['REMOTE_ADDR']."' , '".JRequest::getVar('Song1','', 'post', 'string', '' )."' , '".JRequest::getVar('Song2','', 'post', 'string', '' )."' , '".JRequest::getVar('Song3','', 'post', 'string', '' )."' , '".JRequest::getVar('Song4','', 'post', 'string', '' )."' , '".JRequest::getVar('Song5','', 'post', 'string', '' )."');" );
if (!$database->query()) {
echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>
";
}
?>
Max_admin 04 Sep, 2008
please replace this line :
echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>
";


with

echo $database->getErrorMsg();


tell me if you can see any errors now after submission!
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
danieli 05 Sep, 2008
I am also having issues saving to the database with Chronoforms 3.0 Beta2...

My steps were:
[list]
  • created a new form with e-mail configured and saved it
  • check ed the form off and clicked "create table"
  • did a select all on the fields and let it do the table creation
  • open the form to set the save to db option to "yes"
  • selected the newly created table from the list
  • saved the form
  • clicked the form link to open it in a new tab
  • filled out the form and clicked submit
  • received the form result in my e-mail but noticed my browser was stuck at a white screen (failed to do refresh/redirection)
  • checked the db, no record written
  • tried the code replacement above and tried again with same result
  • [/list]
    Am I doing something wrong?

    FTI... the URL left in the empty browser window is... http://localhost/joomla/index.php?option=com_chronocontact&task=send&chronoformname=NameOfForm
    ... also I noticed my tablename selected in the DB Connection is Jos_Table_Name... while in the Auto-generated code it is just Table_Name... i tried adding both Jos_ and #__ to it with no luck either.

    EDIT:
    I made another couple of "corrections that didn't have any effect either:
    [list=1]
  • noticed in my auto-code that the form field names were defined as hidden,,,,,,,,,,,,,textarea... corrected this to hidden,text,text,text,text,text,text,text,text,text,text,text,text,textarea by adding the type definition to my inputs on the form
  • noticed one of my form fields was named with a "-"within its name... changed this to a "_"
  • [/list:o]
    Max_admin 05 Sep, 2008
    Hi Danieli,

    don't try to edit anything in the auto generated tab, it will not help, its setup the best way, I have a field title typo there though.

    show me your fields names or a screenshot of your created table!

    Cheers

    Max
    Max, ChronoForms developer
    ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
    ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
    danieli 05 Sep, 2008
    I would attach a MySQL table screenie too, but I don't see how to upload an image.

    I found that i missed renaming my "Manager-Supervisor" field to "Manager_Supervisor" in the db so I corrected that as well... still didn't save tho.

    FYI... my tests had all been with FireFox3... tried IE7... instead of a white screen... IE7 reports HTTP 500 error

    here are the form field names as captured on the Auto-Gen page...

    subject,email,ExitingUser,Users_Last_Day,Manager_Supervisor,Department,Access_to_U,AccesstoEmail,Forwardemail,AutorepyNoLongerEmployed,LengthofAutoReply,Access_to_Voicemail,Final_Delete_Date,Comments
    Max_admin 05 Sep, 2008
    ok lets do this:

    remove all those fields from your form code and leave only 2 fields : subject,email, save your form then open it and submit, what happens ?
    Max, ChronoForms developer
    ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
    ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
    danieli 05 Sep, 2008
    the list wasn't truncated... with all the commas it was like one big long word and the web-site couldn't wrap it... I fixed it above.
    danieli 05 Sep, 2008
    oops... I did it with 3 fields... but the the end result was good. The data saved.
    Max_admin 05 Sep, 2008
    good, now add 2 or 3 fields every time until you see where is the problem!
    Max, ChronoForms developer
    ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
    ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
    danieli 05 Sep, 2008
    hmmm, I decided to drop and recreate my table for the larger form... this time, it identified each field with (text) at the end of the line (this was created before i fixed my form input types)...

    this time I didn't get the "white screen"... everything looked like it should have... but it did not save the data to the database... So I guess I am now at the point where the OP is... but what I know is
    [list]
  • 3 of my fields + 4 default fields = not problems saving
  • 14 of my fields + 4 default fields = problems saving
  • [/list]

    Ok, I'll try adding more fields to the smaller form version to see when it breaks.
    danieli 05 Sep, 2008
    ooops... I made a mistake... after I recreated the table for the "big" form, I selected the wrong database in the DB Connection table (similar name, just a 2 on the end for the version)...

    After pointing it to the right database, the db query tool of course pulled out data...

    So it seems to me that my issue was creating my form inputs without explicit types defined... once I properly defined these, and created the database AFTER defining them... all went well.

    My main form is saving all 18 data elements now. Live and learn.
    Max_admin 06 Sep, 2008
    great news! yes you should add type="text" if the field is a text box!
    Max, ChronoForms developer
    ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
    ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
    danieli 08 Sep, 2008
    I think the larger issue was what I realized in another thread... here

    Basically, my dbclasses had become incorrect with the field rename I had done.
    This topic is locked and no more replies can be posted.