Forums

Instructions on how to write & read db

bradolive 28 May, 2008
I've searched, scanned and have not found any simple instructions on what one needs to do to:

1) Have a form's contents written to a database. I know there needs to be code put in onSubmit, but are there some examples?

2) Retrieve the information - i.e. read it back out. I've seen the response for sofia's property listings - and that may make sense if I can figure out how to put data into a database....

Are there any tutorials for that? A hello world, I'm stored and not e-mailed?

I've got a clean Joomla 1.5 with mysql installed. Any pointers would be appreciated.
mja1356 28 May, 2008
Hi
I don't understand what exactly do you want.
do you want to know how to create a form and after submit put data in a table in database? if yes after you create the form in form management a link exist by with name:create table.when you click this another page appear and ask you what fields do you want to put in each column. this is so easy.
do lot nhap khau, annie, do boi nu, thoi trang tre em, thoi trang be trai, do dung cho me sau sinh, thoi trang cong so, vay lien cong so, ban buon quan ao, do lot[/url]
for retrieving data you nedd to put a simple mysql code in form code tab/html to collect data from database.
GreyHead 28 May, 2008
Hi bradolive,

To store data click the 'Create Data Table' link in the Forms Manager view.

To turn off email - set 'Send email' to No in the General tab for your form.

How you retrieve the info depends on what you want to do with it. ChronoForms has a simple record viewer built in.

Bob
bradolive 28 May, 2008
Thanks! Hit me on the head with the Doh! hammer....
rosemary 29 May, 2008
After clicking create table,it gives error "Not enough form fields to create table "Please help me
GreyHead 29 May, 2008
Hi rosemary,

You have to select the fields that you want recorded using the checkboxes at the left. You can 'select all' but you probably don't want 'submit' or 'reset' recorded in the database.

Bob
Max_admin 30 May, 2008
rosemary, either your form code doesn't have fields at all or your field names are written in an improper format like name=field without " " or there are some spaces, the ideal field name is :

name="field_name"

Cheers

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
masshoff 28 Aug, 2008
Hello,

I am trying to set up Chronoforms to write to a db and also send a notification email.

I have followed the steps to create a table and assign that table to the form to write to it.

Now, I am getting the following error on the form page:
Parse error: syntax error, unexpected '$', expecting T_VARIABLE in /home/hudson/public_html/site/components/com_chronocontact/chronocontact.php(48) : eval()'d code on line 13

and this error upon submission:
Parse error: syntax error, unexpected '$', expecting T_VARIABLE in /home/hudson/public_html/site/components/com_chronocontact/chronocontact.php(48) : eval()'d code on line 13

Fatal error: Call to a member function bind() on a non-object in /home/hudson/public_html/site/components/com_chronocontact/chronocontact.php(577) : eval()'d code on line 10

These errors go away if I disable db storage.

Any help?

Thanks in advance,

MASS
GreyHead 28 Aug, 2008
Hi masshoff,

Looks like there is a typo somewhere in Line 13 of the Autogenerated code. Can you please paste it here for us to take a look.

Bob
masshoff 28 Aug, 2008
here is the auto generated code from the ChronoForm control panel. Thanks in advance!

<div class="form_item"><div class="form_element cf_heading"><h1 id="" class="cf_text">Teacher Integration Project</h1></div><div class="clear"> </div></div><div class="form_item"><div class="form_element cf_heading"><h2 id="" class="cf_text">Application Form</h2></div><div class="clear"> </div></div>

<div class="form_item"><div class="form_element cf_text"><span class="cf_text">In an effort to assist teachers in incorporating new media into their teaching studios, Hudson Music has formed the TIP - Teacher Integration Project - a group comprised of private teachers and leading educators.</span></div><div class="clear"> </div></div>

<div class="form_item"><div class="form_element cf_text"><span class="cf_text">We welcome participation in this group to any and all teachers who currently use or are interested in learning how to better incorporate new media into their studios to provide better experiences and learning opportunities for their students!</span></div><div class="clear"> </div></div>

<div class="form_item"><div class="form_element cf_text"><span class="cf_text">Please take a moment to register in the program, and answer a few short questions below to help us better understand our TIP members.</span></div><div class="clear"> </div></div>

<div class="form_item"><div class="form_element cf_textbox"><label class="cf_label">Name</label><input class="cf_inputbox required" maxlength="150" size="30" id="text_12" name="text_12" type="text"><a onclick="return false;" class="tooltiplink"><img  src="components/com_chronocontact/css/images/tooltip.png" class="tooltipimg" border="0" height="12" width="12"></a><div class="tooltipdiv">Name :: Enter Your Name</div></div><div class="clear"> </div></div>

<div class="form_item"><div class="form_element cf_textbox"><label class="cf_label">Email</label><input class="cf_inputbox required validate-email" maxlength="150" size="30" id="text_14" name="text_14" type="text"><a onclick="return false;" class="tooltiplink"><img  src="components/com_chronocontact/css/images/tooltip.png" class="tooltipimg" border="0" height="12" width="12"></a><div class="tooltipdiv">Email :: Enter Your Email Address</div></div><div class="clear"> </div></div>

<div class="form_item"><div class="form_element cf_textbox"><label class="cf_label">Street Address</label><input class="cf_inputbox" maxlength="150" size="30" id="text_16" name="text_16" type="text"><a onclick="return false;" class="tooltiplink"><img  src="components/com_chronocontact/css/images/tooltip.png" class="tooltipimg" border="0" height="12" width="12"></a><div class="tooltipdiv">Street Address :: Enter Your Street Mailing Address</div></div><div class="clear"> </div></div>

<div class="form_item"><div class="form_element cf_textbox"><label class="cf_label">City</label><input class="cf_inputbox" maxlength="150" size="30" id="text_15" name="text_15" type="text"><a onclick="return false;" class="tooltiplink"><img  src="components/com_chronocontact/css/images/tooltip.png" class="tooltipimg" border="0" height="12" width="12"></a><div class="tooltipdiv">City :: Enter your City</div></div><div class="clear"> </div></div><div class="form_item">

<div class="form_element cf_textbox"><label class="cf_label">State</label><input class="cf_inputbox" maxlength="35" size="4" id="text_13" name="text_13" type="text"><a onclick="return false;" class="tooltiplink"><img  src="components/com_chronocontact/css/images/tooltip.png" class="tooltipimg" border="0" height="12" width="12"></a><div class="tooltipdiv">State :: Enter Your State</div></div><div class="clear"> </div></div>

<div class="form_item"><div class="form_element cf_textbox"><label class="cf_label">Zip/Postal Code</label><input class="cf_inputbox" maxlength="30" size="10" id="text_11" name="text_11" type="text"><a onclick="return false;" class="tooltiplink"><img  src="components/com_chronocontact/css/images/tooltip.png" class="tooltipimg" border="0" height="12" width="12"></a><div class="tooltipdiv">Zip/Postal Code :: Enter Your Zip or Postal code</div></div><div class="clear"> </div></div>

<div class="form_item"><div class="form_element cf_dropdown"><label class="cf_label">Country</label><select class="cf_inputbox validate-selection" id="select_10" size="1" name="select_10"><option value="No Country">Please Choose</option><option value="United States">United States</option><option value="Canada">Canada</option><option value="United Kingdom">United Kingdom</option><option value="France">France</option><option value="Germany">Germany</option><option value="Italy">Italy</option><option value="Afghanistan">Afghanistan</option><option value="Albania">Albania</option><option value="Algeria">Algeria</option><option value="Andorra">Andorra</option><option value="Angola">Angola</option><option value="Antigua & Deps">Antigua & Deps</option><option value="Argentina">Argentina</option><option value="Armenia">Armenia</option><option value="Australia">Australia</option><option value="Austria">Austria</option><option value="Azerbaijan">Azerbaijan</option><option value="Bahamas">Bahamas</option><option value="Bahrain">Bahrain</option><option value="Bangladesh">Bangladesh</option><option value="Barbados">Barbados</option><option value="Belarus">Belarus</option><option value="Belgium">Belgium</option><option value="Belize">Belize</option><option value="Benin">Benin</option><option value="Bhutan">Bhutan</option><option value="Bolivia">Bolivia</option><option value="Bosnia Herzegovina">Bosnia Herzegovina</option><option value="Botswana">Botswana</option><option value="Brazil">Brazil</option><option value="Brunei">Brunei</option><option value="Bulgaria">Bulgaria</option><option value="Burkina">Burkina</option><option value="Burundi">Burundi</option><option value="Cambodia">Cambodia</option><option value="Cameroon">Cameroon</option><option value="Canada">Canada</option><option value="Cape Verde">Cape Verde</option><option value="Central African Rep">Central African Rep</option><option value="Chad">Chad</option><option value="Chile">Chile</option><option value="China">China</option><option value="Colombia">Colombia</option><option value="Comoros">Comoros</option><option value="Congo">Congo</option><option value="Congo {Democratic Rep}">Congo {Democratic Rep}</option><option value="Costa Rica">Costa Rica</option><option value="Croatia">Croatia</option><option value="Cuba">Cuba</option><option value="Cyprus">Cyprus</option><option value="Czech Republic">Czech Republic</option><option value="Denmark">Denmark</option><option value="Djibouti">Djibouti</option><option value="Dominica">Dominica</option><option value="Dominican Republic">Dominican Republic</option><option value="East Timor">East Timor</option><option value="Ecuador">Ecuador</option><option value="Egypt">Egypt</option><option value="El Salvador">El Salvador</option><option value="Equatorial Guinea">Equatorial Guinea</option><option value="Eritrea">Eritrea</option><option value="Estonia">Estonia</option><option value="Ethiopia">Ethiopia</option><option value="Fiji">Fiji</option><option value="Finland">Finland</option><option value="France">France</option><option value="Gabon">Gabon</option><option value="Gambia">Gambia</option><option value="Georgia">Georgia</option><option value="Germany">Germany</option><option value="Ghana">Ghana</option><option value="Greece">Greece</option><option value="Grenada">Grenada</option><option value="Guatemala">Guatemala</option><option value="Guinea">Guinea</option><option value="Guinea-Bissau">Guinea-Bissau</option><option value="Guyana">Guyana</option><option value="Haiti">Haiti</option><option value="Honduras">Honduras</option><option value="Hungary">Hungary</option><option value="Iceland">Iceland</option><option value="India">India</option><option value="Indonesia">Indonesia</option><option value="Iran">Iran</option><option value="Iraq">Iraq</option><option value="Ireland {Republic}">Ireland {Republic}</option><option value="Israel">Israel</option><option value="Italy">Italy</option><option value="Ivory Coast">Ivory Coast</option><option value="Jamaica">Jamaica</option><option value="Japan">Japan</option><option value="Jordan">Jordan</option><option value="Kazakhstan">Kazakhstan</option><option value="Kenya">Kenya</option><option value="Kiribati">Kiribati</option><option value="Korea North">Korea North</option><option value="Korea South">Korea South</option><option value="Kosovo">Kosovo</option><option value="Kuwait">Kuwait</option><option value="Kyrgyzstan">Kyrgyzstan</option><option value="Laos">Laos</option><option value="Latvia">Latvia</option><option value="Lebanon">Lebanon</option><option value="Lesotho">Lesotho</option><option value="Liberia">Liberia</option><option value="Libya">Libya</option><option value="Liechtenstein">Liechtenstein</option><option value="Lithuania">Lithuania</option><option value="Luxembourg">Luxembourg</option><option value="Macedonia">Macedonia</option><option value="Madagascar">Madagascar</option><option value="Malawi">Malawi</option><option value="Malaysia">Malaysia</option><option value="Maldives">Maldives</option><option value="Mali">Mali</option><option value="Malta">Malta</option><option value="Marshall Islands">Marshall Islands</option><option value="Mauritania">Mauritania</option><option value="Mauritius">Mauritius</option><option value="Mexico">Mexico</option><option value="Micronesia">Micronesia</option><option value="Moldova">Moldova</option><option value="Monaco">Monaco</option><option value="Mongolia">Mongolia</option><option value="Montenegro">Montenegro</option><option value="Morocco">Morocco</option><option value="Mozambique">Mozambique</option><option value="Myanmar">Myanmar</option><option value="Namibia">Namibia</option><option value="Nauru">Nauru</option><option value="Nepal">Nepal</option><option value="Netherlands">Netherlands</option><option value="New Zealand">New Zealand</option><option value="Nicaragua">Nicaragua</option><option value="Niger">Niger</option><option value="Nigeria">Nigeria</option><option value="Norway">Norway</option><option value="Oman">Oman</option><option value="Pakistan">Pakistan</option><option value="Palau">Palau</option><option value="Panama">Panama</option><option value="Papua New Guinea">Papua New Guinea</option><option value="Paraguay">Paraguay</option><option value="Peru">Peru</option><option value="Philippines">Philippines</option><option value="Poland">Poland</option><option value="Portugal">Portugal</option><option value="Qatar">Qatar</option><option value="Romania">Romania</option><option value="Russian Federation">Russian Federation</option><option value="Rwanda">Rwanda</option><option value="St Kitts & Nevis">St Kitts & Nevis</option><option value="St Lucia">St Lucia</option><option value="St Vincent & Gr/dines">St Vincent & Gr/dines</option><option value="Samoa">Samoa</option><option value="San Marino">San Marino</option><option value="Sao Tome & Principe">Sao Tome & Principe</option><option value="Saudi Arabia">Saudi Arabia</option><option value="Senegal">Senegal</option><option value="Serbia">Serbia</option><option value="Seychelles">Seychelles</option><option value="Sierra Leone">Sierra Leone</option><option value="Singapore">Singapore</option><option value="Slovakia">Slovakia</option><option value="Slovenia">Slovenia</option><option value="Solomon Islands">Solomon Islands</option><option value="Somalia">Somalia</option><option value="South Africa">South Africa</option><option value="Spain">Spain</option><option value="Sri Lanka">Sri Lanka</option><option value="Sudan">Sudan</option><option value="Suriname">Suriname</option><option value="Swaziland">Swaziland</option><option value="Sweden">Sweden</option><option value="Switzerland">Switzerland</option><option value="Syria">Syria</option><option value="Taiwan">Taiwan</option><option value="Tajikistan">Tajikistan</option><option value="Tanzania">Tanzania</option><option value="Thailand">Thailand</option><option value="Togo">Togo</option><option value="Tonga">Tonga</option><option value="Trinidad & Tobago">Trinidad & Tobago</option><option value="Tunisia">Tunisia</option><option value="Turkey">Turkey</option><option value="Turkmenistan">Turkmenistan</option><option value="Tuvalu">Tuvalu</option><option value="Uganda">Uganda</option><option value="Ukraine">Ukraine</option><option value="United Arab Emirates">United Arab Emirates</option><option value="United Kingdom">United Kingdom</option><option value="United States">United States</option><option value="Uruguay">Uruguay</option><option value="Uzbekistan">Uzbekistan</option><option value="Vanuatu">Vanuatu</option><option value="Vatican City">Vatican City</option><option value="Venezuela">Venezuela</option><option value="Vietnam">Vietnam</option><option value="Yemen">Yemen</option><option value="Zambia">Zambia</option><option value="Zimbabwe">Zimbabwe</option></select><a onclick="return false;" class="tooltiplink"><img  src="components/com_chronocontact/css/images/tooltip.png" class="tooltipimg" border="0" height="12" width="12"></a><div class="tooltipdiv">Country :: Choose a Country from the Drop Down menu</div></div><div class="clear"> </div></div>

<div class="form_item"><div class="form_element cf_textarea"><label class="cf_label">What is the name of the school or store where you currently teach?</label><textarea class="cf_inputbox required" rows="3" id="text_18" cols="30" name="text_18"></textarea></div><div class="clear"> </div></div>

<div class="form_item"><div class="form_element cf_textarea"><label class="cf_label">Are you using electronic media (CDs, DVDs, iPod, computers, online lessons, websites, video, etc.) in your teaching?</label><textarea class="cf_inputbox required" rows="3" id="text_19" cols="30" name="text_19"></textarea></div><div class="clear"> </div></div>

<div class="form_item"><div class="form_element cf_checkbox"><label class="cf_label">How many students do you currently teach?</label><div class="float_left"><input value="1-5" class="radio validate-one-required" id="1-5" name="1-5" type="checkbox"><label for="1-5" class="check_label">1-5</label><br><input value="6-10" class="radio" id="6-10" name="6-10" type="checkbox"><label for="6-10" class="check_label">6-10</label><br><input value="11-20" class="radio" id="11-20" name="11-20" type="checkbox"><label for="11-20" class="check_label">11-20</label><br><input value="20 or more" class="radio" id="20_or more" name="20_or more" type="checkbox"><label for="20_or more" class="check_label">20 Or More</label><br></div></div><div class="clear"> </div></div>

<div class="form_item"><div class="form_element cf_button"><input value="Submit" name="undefined" type="submit"></div><div class="clear"> </div></div>
GreyHead 28 Aug, 2008
Hi masshoff,

That looks like the code from the Form HTML box - it's the code on the Autogenerated Code tab we need for this.

Bob
masshoff 28 Aug, 2008
oops -
<?php
		if($paramsvalues->dbconnection == "Yes"){			
			$row =& JTable::getInstance("chronoforms_TIP", "Table");
			srand((double)microtime()*10000);
			$inum	=	"I" . substr(base64_encode(md5(rand())), 0, 16);
			$_POST["recordtime"] 	= JRequest::getVar( "recordtime", date("Y-m-d")." - ".date("H:i:s"), "post", "string", "" );
			$_POST["ipaddress"] 	= JRequest::getVar( "ipaddress", $_SERVER["REMOTE_ADDR"], "post", "string", "" );
			$_POST["uid"] 	= JRequest::getVar( "uid", $inum, "post", "string", "" );
			$post = JRequest::get( "post" , JREQUEST_ALLOWRAW );			
			if (!$row->bind( $post )) {
				echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";
				exit();
			}				
			if (!$row->store()) {
				echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";
				exit();
			}			
		}
		?>
		
Max_admin 29 Aug, 2008
Hi Mass,

please open your form at the admin area and save it again and then retest, if this didn't work then remove any sensitive info and backup your form and attach it here, I need to check something!

Regards,

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
masshoff 29 Aug, 2008
still no luck.

file attached. thanks for all the help!
Max_admin 29 Aug, 2008
Hi, I see you have column names called "1-5", thats wrong, open your table in phpmyadmin and make this like "1_5" and any other fields with similar names then open the form and save it again to reinitialize the DB table class and it should work! you can create another table and connect to it as well!
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
masshoff 29 Aug, 2008
Hi and thanks for the reply.

That did NOT seem to fix the issue. Went into the table and changed column names - still getting the same error.

I tried recreating the table as well - this time not using "-" but using "_" instead.

same problem - same error.

any thoughts?
Max_admin 29 Aug, 2008
please backup your table structure and put it here and I will restore it and test on my machine! please put the SQL directly into the forum post code tags.
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
masshoff 04 Sep, 2008
hopefully this is what you need. thanks in advance for the help.

-- phpMyAdmin SQL Dump
-- version 2.11.6
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Sep 03, 2008 at 08:53 PM
-- Server version: 4.1.22
-- PHP Version: 5.2.6

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

--
-- Database: `hudson_jom`
--

-- --------------------------------------------------------

--
-- Table structure for table `jos_chronoforms_TIP`
--

CREATE TABLE IF NOT EXISTS `jos_chronoforms_TIP` (
  `cf_id` int(11) NOT NULL auto_increment,
  `uid` varchar(255) NOT NULL default '',
  `recordtime` text NOT NULL,
  `ipaddress` text NOT NULL,
  `text_12` varchar(255) NOT NULL default '',
  `text_14` varchar(255) NOT NULL default '',
  `text_16` varchar(255) NOT NULL default '',
  `text_15` varchar(255) NOT NULL default '',
  `text_13` varchar(255) NOT NULL default '',
  `text_11` varchar(255) NOT NULL default '',
  `1_5` varchar(255) NOT NULL default '',
  `6_10` varchar(255) NOT NULL default '',
  `11_20` varchar(255) NOT NULL default '',
  `20_plus` varchar(255) NOT NULL default '',
  `select_10` varchar(255) NOT NULL default '',
  `text_18` varchar(255) NOT NULL default '',
  `text_19` varchar(255) NOT NULL default '',
  PRIMARY KEY  (`cf_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

--
-- Dumping data for table `jos_chronoforms_TIP`
--
Max_admin 04 Sep, 2008
Hi, we have fixed similar issue earlier today, fields names cant start with numbers! change them and all will be fine

Cheers

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
masshoff 04 Sep, 2008
that did it. stupid error on my part.

thanks - great help on these forums!
Max_admin 04 Sep, 2008
Thanks, No problems really, this is how we learn😉

Cheers

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
gccompserv2 16 Sep, 2008
Would field names beginning with an * cause the same problem?

I use an asterisk to indicate a required field.

Thanks!
Max_admin 17 Sep, 2008
sure, its not HTML good or db column name too to have a name starting with *
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.