Forums

Database-records aren't visible

maximus 10 Jan, 2009
Hi,

For a community-website I'm working on, I need to make a form where members could give their dinner-preference for our weekly meeting. I'm not an expert-programmer, but I have to say that making forms with ChronoForms is really easy. But I have a problem right now, my data isn't saved in the table!

What I've done:
- I've made the form with the form-wizard
- I've created a table with the "Create Table"-option in the form-manager
- At the edit-page of the form I've selected the "Enable data-storage"-option under the "DB-Connection"-section and selected the made table.

I've enabled the debug-option at my joomla-installation, but with no effect, I didn't find any error concerning this problem.

What am I doing wrong?

Many thanks in advance!

My form-code:
...Some Intro-text...

// Input-box
<DIV class=form_item   >
<DIV class="form_element cf_textbox" ><LABEL class=cf_label >Name</LABEL><INPUT class=cf_inputbox id=text_4  maxLength=150 size=30 name=namefield value="<?php $user = &JFactory::getUser();echo $user->name;?>" disabled=true> </DIV>
<DIV class=clear > </DIV></DIV>

// Input-box
<DIV class=form_item   >
<DIV class="form_element cf_textbox" ><LABEL class=cf_label >Dinner</LABEL><INPUT class=cf_inputbox id=text_8  maxLength=150 size=30 name=dinnerprevfield disabled=true></DIV>
<DIV class=clear > </DIV></DIV>

// Input-box
<DIV class=form_item   >
<DIV class="form_element cf_textbox" ><LABEL class=cf_label >Pizza</LABEL><INPUT class=cf_inputbox id=text_7  maxLength=150 size=30 name=pizzaprevfield disabled=true></DIV>
<DIV class=clear > </DIV></DIV>

// Input-box
<DIV class=form_item   >
<DIV class="form_element cf_textbox" ><LABEL class=cf_label >Soho1</LABEL><INPUT class=cf_inputbox id=text_9  maxLength=150 size=30 name=soho1prevfield disabled=true></DIV>
<DIV class=clear > </DIV></DIV>

// Input-box
<DIV class=form_item   >
<DIV class="form_element cf_textbox" ><LABEL class=cf_label >Soho2</LABEL><INPUT class=cf_inputbox id=text_12  maxLength=150 size=30 name=soho2prevfield disabled=true></DIV>
<DIV class=clear > </DIV></DIV>

// Input-box
<DIV class=form_item   >
<DIV class="form_element cf_textbox" ><LABEL class=cf_label >Drink</LABEL><INPUT class=cf_inputbox id=text_10  maxLength=150 size=30 name=drinkprevfield disabled=true></DIV>
<DIV class=clear > </DIV></DIV>

// Drop-down box
<DIV class=form_item   >
<DIV class="form_element cf_dropdown" ><LABEL class=cf_label >Dinner</LABEL><SELECT class=cf_inputbox id=select_17 size=1 name=dinnerfield onChange="changeprev(this, this.form.pizzafield, this.form.soho1field, this.form.soho2field);"> 	<option value="NoFood">No Food</option>
 	<option value="Pizza">Pizza</option>
 	<option value="Soho">Soho</option> </SELECT></DIV>
<DIV class=clear > </DIV> </DIV>

// Drop-down box
<DIV class=form_item   >
<DIV class="form_element cf_dropdown" ><LABEL class=cf_label >Pizza</LABEL><SELECT class=cf_inputbox id=select_18 size=1 name=pizzafield disabled=true> <option value="margherita" selected>Margherita</option>
    <option value="salami">Salami</option>
   ...Some other options...
    <option value="calzone">Calzone</option> </SELECT></DIV>
<DIV class=clear > </DIV></DIV>

// Drop-down box
<DIV class=form_item   >
<DIV class="form_element cf_dropdown" ><LABEL class=cf_label >Soho1</LABEL><SELECT class=cf_inputbox id=select_19 size=1 name=soho1field disabled=true >     <option value="thai chicken" selected>Thai Chicken</option>
    <option value="kon bon chicken">Kon Bon Chicken</option>
    ...Some other options...
    <option value="gado gado">Gado Gado</option> </SELECT></DIV>
<DIV class=clear > </DIV></DIV>

// Drop-down box
<DIV class=form_item   >
<DIV class="form_element cf_dropdown" ><LABEL class=cf_label >Soho2</LABEL><SELECT class=cf_inputbox id=select_21 size=1 name=soho2field disabled=true >     <option value="rice">Rice</option>
    <option value="noodles">Noodles</option> </SELECT></DIV>
<DIV class=clear > </DIV></DIV>

// Drop-down box
<DIV class=form_item   >
<DIV class="form_element cf_dropdown" ><LABEL class=cf_label >Drink</LABEL><SELECT class=cf_inputbox id=select_16 size=1 name=drinkfield >     <option value="no drink" selected>No Drink</option>
    <option value="cola">Cola</option>
   ...Some other options...
    <option value="cassis">Cassis</option> </SELECT></DIV>
<DIV class=clear > </DIV></DIV>

// Send-button
<DIV class=form_item   >
<DIV class="form_element cf_button" ><INPUT  type=submit value=Submit ></DIV>
<DIV class=clear > </DIV></DIV>
GreyHead 10 Jan, 2009
Hi Maximus,

It looks as though all your input fields are disabled so won't return any data. Is the problem that No records are being saved or that records are being saved with no data in them??

Bob
maximus 10 Jan, 2009
Hi Bob,

Thanks for your quick reply.

I also have to say that for the first 6 input-fields I do not need the results. Those fields must become fields where I get information out of the database and display to the user, but that is an issue for later time. When I created my table, I didn't select those fields to become a datafield in the table. For the other fields that are disabled, they become enabled again, depending at the choice made in the first Drop-down box (Done with my own javascript onChange="changeprev(this, this.form.pizzafield, this.form.soho1field, this.form.soho2field);").

The datarecords aren't saved at all.
Max_admin 10 Jan, 2009
Hi maximus,

open the form and don't fill any data and submit it once, now look at the table records, does a new record get saved ?

Cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
maximus 11 Jan, 2009
Hi Max,

With an empty form, no data-record is saved again.
GreyHead 11 Jan, 2009
Hi Maximus,

We're going to struggle to diagnose this remotely.
[sendfb][/sendfb]
Bob
maximus 11 Jan, 2009
Hi Bob!

That would be real nice! See the attachment for the Form.

Many thanks for the help!
GreyHead 11 Jan, 2009
Hi Maximus,

Cracked it :-) you have the Autogenerated code set to run 'Before Emails' AND you have the General Tab | Email the Results? set to NO.

With 'Email the Results?' set to NO neither the OnSubmit Before Code, not the 'Autogenerated + Before Emails' code is run.

Either turn Email the Results to YES or switch the Autogenerated Code back to (the default) 'After Emails' and all will be well.

Bob
maximus 11 Jan, 2009
Whoottt! 😀

Thank you very much for your quick support! It's working!
maximus 11 Jan, 2009
Okay, my form is working now correctly but now I want to implement the following:

When a user gives in his dinner-preference for the second time, the data-record of the first time should be deleted. I've came up with the following chunck of php-code:
<?php
$user = &JFactory::getUser();
$username = $user->name;

// Search if we allready have name in database
$query = sprintf("SELECT * FROM `jos_chronoforms_dinnerpreferenceteamavond` WHERE  `namefield` = '%s'" , $username);
$result = mysql_query($query) or die('Error, Search failed'.mysql_error());
  
// We have name in database
if (mysql_num_rows($result) >= 1)
{
	
  // Delete existing tuple
  $query = "DELETE FROM `jos_chronoforms_dinnerpreferenceteamavond` WHERE namefield = '".$username."';";
  mysql_query($query) or die('Error, delete query failed'.mysql_error());
}
?>


But in which field of the editing-part should this code be added? And remember, the old record should only be deleted when a new record is submitted.

Many thanks in advance!
GreyHead 12 Jan, 2009
Hi maximus,

You probably need to use a MySQL REPLACE statement instead of INSERT + DELETE

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