Forums

Submit to form DB then Display as Contents

akubeejays 29 Oct, 2008
I've been searching around the forum and couldn't quite find sumthing close to what i want to do.. (maybe i'm blind) but could you help me out.

I have one form. A very simple and small form. What i want to do is first... insert the data into a table . The exact steps i took were

1) create form
2) create table for the form using the create table button
3) enable data storage
4) select the table i want to use.. and save

ALL DONE on this (but have not tested.. i believe you guys have debugged this part time and time again.. so i trust it will work perfectly) I like to do things on one go and test on one go as well.. i suppose thats one of my lazy traits😛


the second thing i want to do is....submit the contents of this form as a contents. Now this is where i don't know what to do.

what should i do & use to retrieve all values from the form and insert it into the jos_content table? (take note that all my form values will be only used in my contents TEXT)

I guess that breaks the question into 2 or 3 parts

Where to do it? since i do not send emails.. i think its not on the form code page... is it correct to use it on the autogenerate page?

If so.... how do i retrieve the values ? i saw something similiar at http://www.chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=4&t=11425&p=15971&hilit=sql#p15971 but my autogenerated code for the form db insert is no where near looking like that.



if my forms fields are text_2,text_3,text_12,text_8

should i use

 mosGetParam($_POST,'text_2','')


and what should i use for the database connection since i assume its already connected (being used to submit into the form db) (i'd like to avoid defining another db connection)


Sorry for my lengthy explained question
Max_admin 29 Oct, 2008
Hi, there is a simple form backup file to restore at your Chronoforms which will do the content submission part, check this in the Downloads/Chrono Applications/

Cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
akubeejays 30 Oct, 2008
hmm.. ok i checked out your example. although i have no idea where to edit, i have a better view.

basically... to insert into one field in the DB, the field of the form item has to be the same name as the field? (this is what i'm seeing based on the example)

but even so...

my purpose is

1) to insert into 2 db at the same time. and i still dun have any idea how to do that. where would i modify the code to do this ?
2) eventhough i would like to post the contents (into the jos_contents table), the reason why i separated the fields is so i can publish the contents in a format that i would wish it to be published. so basically the form fields would eventually need to be combined as per my own structure and only then save to the jos content table
akubeejays 30 Oct, 2008
found it..........


$database =& JFactory::getDBO();

$database->setQuery( "insert statement" );
if (!$database->query()) {
echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>
";
} 


after the code in auto generate.

But found a bug ( i think) . For some reason i can't save code i added in autogenerate (J1.5,CF3). But if i edit it directly in my DB it seems to work fine.So my problem is solved. Anyway. Great job on the component. expect my vote in joomla.org as well🙂
Max_admin 30 Oct, 2008
Hi akubeejays,

Thanks for the great vote!

I suggest you don't edit the auto generated code, whats your problem with the values ? you need to do some processing changes on the data before its inserted ?

this is so easy, when you restore the form we have for submit content, you will see in the "on submit" code box that some changes can be done on posted values, just do it the same way!

Cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
akubeejays 30 Oct, 2008
Well, that would help.. but i need the ID for the insert string to the "form table" before i can insert into the contents table. This way.. i can grab the unique id for the form insert.

My idea is to later create another form that will be used to edit the values. To do this the user has to click on a button thats in the contents page. (that was coded in and appended to the contents text during submit)

This way, users are still forced to follow MY contents structure instead of creating their own. And i won't have to parse their contents to the edit form fields.

but now that i think of it...i suppose a manual insert into both tables on submit, and not using the db insert would help me get the same effects though😀 heehehe... now i have to think of which method to use during my drive to work hahaha
Max_admin 31 Oct, 2008
Hi akubeejays,

If you got the form connected to 2 tables then the 2 tables will have the data inserted, if you want the id of the record inserted at the form own tabl then I can help you know how to get it, if you are happy with the way you are doing it then this is fine but the chronoforms auto generated code is more safe and is using the Joomla codespace!

Cheers
Max
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.