putting the form fields into the other database

sapna 19 Jan, 2009
hi,
I just wanna know, how do i put the form fields data into the other database 🤨 🤨

please help me..
GreyHead 19 Jan, 2009
Hi sapna,

What form fields? into what other database?

Have you looked at the Database tutorial in the downloads area here?

Bob
sapna 20 Jan, 2009
hi bob,
thanks for your reply.
Actually I have created a registration form with the help of chronoforms.
now i want these registration fileds, like name,lastname,age,etc.. to go into the other database. say into the contact table of sugarcrm database.
how do i do that ???
GreyHead 20 Jan, 2009
Hi sapna,

In the OnSubmit After box of ChronoForms you can enter the PHP & MySQL to write to another database - assuming that you have the appropriate permissions. I posted the Joomla code to create a connection to another database here about a week ago (not sure where now though).

Bob
sapna 21 Jan, 2009
hi bob,

i entered the following code in Form Code tab under [On Submit code - before sending email:]
<?php
$host = 'localhost';
 	$port = '3306';
 	$dbuser = 'root';
 	$pass = 'root';
 	$con = mysql_connect("$host:$port","$dbuser","$pass");
 	if (!$con)
  	 {
  		 die('Could not connect: ' . mysql_error());
  	 }
 	mysql_select_db("test", $con);
        mysql_query("insert into `info` (`fname`,`lname`) values('text_7','text_8');");
?> 

the values dint inserted into the test database. could u please check??? I also add this code in Extra after onsubmit code: dint worked :? :?
GreyHead 21 Jan, 2009
Hi sapna,

This looks OK, but it certainly isn't the Joomla database code that I posted. Please look that up.

Bob
sapna 21 Jan, 2009
i checked most of the forums.. but could find any..
if u remember please paste it here.
will be very must thankful to you..
sapna 21 Jan, 2009
hi all,

is this possible ?? that registration fields data to pass into other database table.
sapna 21 Jan, 2009
thanks Bob,

but can u tell me how do I run mi insert query ????

and where should i write this code ??
sapna 21 Jan, 2009
I tried this...

<?php
    <?php
    $options = array('host' => 'localhost', 'user' => 'root', 'password' => 'root', 'database' => 'test', 'prefix' = '', 'select' => 'info');
    $db2 =& new JDatabaseMySQL($options);
    ?>
        $db2->setQuery("insert into `info` (`fname`,`lname`) values('text_7','text_8');");
?>

dint worked ????

where am i going wrong ??

please help me out.
GreyHead 21 Jan, 2009
Hi sapna,

When you say 'didn't work' - exactly what did you test and what happened?

It is close to impossible to make any useful diagnosis from 'didn't work'. You need to add debug code at each step and check exactly what is happening.

Bob
sapna 21 Jan, 2009
hi,

sorry i should be specific, i mean to say that the value of the id text_7 and text_8 are not getting inserted into the info table of the test database.
I also made the database connection as u said. but no result.
i also set the debug to ON.
_POST: Array ( [text_0] => aa [text_1] => aa [text_2] => [email]aa@gmail.com[/email] [text_3] => sasasa [text_6] => sasasa [text_7] => sa [text_8] => sa [undefined] => Submit [56852eccd7312bfb62310863449fa20b] => 1 ) this is what it shows me in debug.
sapna 21 Jan, 2009
hi bob,

it worked with my previous code !!!
thanks a lot.
GreyHead 21 Jan, 2009
Hi sapna,

Great, glad it's working. Looks at though the Joomla version didn't work because you have a setQuery but haven't actually executed the query, needs a $db2->query(); as well.

Bob
gocasco 01 Apr, 2009
which code version worked?
and what steps were taken to ensure the data was written into the appropriate fields?
gocasco 01 Apr, 2009
which code is the correct one?

the poster refers to the "previous code", but I don't want to assume which one that is.
GreyHead 02 Apr, 2009
Hi gocasco,

What exactly do you need to do?

Bob
Max_admin 02 Apr, 2009
Hi gocasco,

the code in this post will simple create a new DB connection and DB object to a new different database (probably your CRM one) and then you can use the normal Joomla DB functions to insert the CRM data!

Regards
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.