send multiple value in email template and database

san26 08 Jul, 2007
hi all,
please help !!!!!

i have a form with mulitple selection box, i have follow all steps properly, but not getting email properly.
if i dont add "[]" in the select box name, i get email, but not multiple value.. if i use select box name with "[]" i get empty email ???? please let me know where im wrong.. im using version 2.0

below the form
------------
<select name="san[]" multiple size="5">
<option value="select1">select1</option>
<option value="select2">select2</option>
<option value="select3">select3</option>
<option value="select4">select4</option>
<option value="select5">select5</option>
</select>
---------
i have added a Arry name for this select box to get value in array.. and i have also added "On Submit code"
------------
<?php
if ( is_array($_POST[san]) ) {
$_POST[san] = implode(',', $_POST[san]);
}
?>
------------
and in email template i have added
---------
<p> Subject: {san} </p>
---------

and in the "Auto generated" tab, i have added this
-----------
<?php
global $database;

if ( is_array($_POST[san]) ) {
$_POST[san] = implode(',', $_POST[san]);
}


$database->setQuery( "INSERT INTO #__chronoforms_9 VALUES (
'' , '". date('Y-m-d')." - ".date("H:i:s")."' , '".$_POST[san]."');" );
if (!$database->query()) {
echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>
";
}
?>
----------

i know solution is there, but really dont know where im doing wrong ?

please help me out
thanks in advance

san
GreyHead 08 Jul, 2007
Hi San,

Please will you upgrade to the latest version v2.2.1 as Max has fixed some earlier problems with the array support in this version.

Hopefully this will fix your problem but if not then I'll take a closer look.

Bob
san26 08 Jul, 2007
Hi Bob,
thanks for your message..
do i need to make all forms again, if i update new version??

or how i can update new version without lossing old data??

please let me know
thanks
san
GreyHead 08 Jul, 2007
Hi san,

To upgrade, the easy way is to FTP the revised files and over-write the previous version. I've attached a little patch file that should upgrade your installation from v2.0 to v2.2.1

Note 1 for other readers, this is not a full install package, it should be OK to upgrade from either v2.0 or v2.1.4 but take care and back up first!!!!

Note 2 if you store form results to the database there are some changes in v2.0. Back up all your form tables before doing the upgrade. I think that you may need to use PHPMyAdmin to add an extra field to the tables. Proceed with great care and check each step.

Bob

PS Sorry, buggy zip file - trying again<br><br>Post edited by: GreyHead, at: 2007/07/08 17:33
GreyHead 08 Jul, 2007
Here's the revised patch file. Bob [file name=chronoforms_2-de0055cd32a70da90933d5da4222fec5.zip size=36982]http://www.chronoengine.com/components/com_fireboard/uploaded/files/chronoforms_2-de0055cd32a70da90933d5da4222fec5.zip[/file]
Max_admin 10 Jul, 2007
Hi San, Bob,

ASA I get back I will have a solution for the backup problem which became big in the last few days as much users like to upgrade!!

San, Can you wait about 10 days for the "upgrade with ease" new patch ?

If not then you can use Bob's solution OR if you just have 1 form then it wont take more than 5 minutes to copy your code and parameters from the ChronoForms admin then uninstall then reinstall and paste them in again, only 3 minutes per form if you have much configs!!

Cheers

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
san26 11 Jul, 2007
hi Max and Bob,

i have install new version " ChronoForms V 2.2.1"
but still facing same problem..

im sending multiple field value in email subject field.. its going fine in subject link but still no "my template" email going emptly ?? it storing mutliple value in the database... and sending same mulitple value in subject but not in message..

im not understand where is wrong.. why its sending emptly email..

if i replace "san[]" to "san", email start sending proper but single value (not multiple.. as you know i need multiple value in email and database too"

please give me solution.. i will be very think ful to you
thanks in advance
san
GreyHead 11 Jul, 2007
Hi San,

I'll try to re-create your form and see if I can replicate the problem.

Bob
Max_admin 11 Jul, 2007
Hi San,

Could you please make a new form and dont put any autogenerated code or onsubmit code ? just the HTML and then test when sending emails with "field names" and with "my template", what happens ?

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
san26 12 Jul, 2007
hi MAX
i have tried a new form and seen this error
----------
Warning: preg_replace() [function.preg-replace]: Compilation failed: missing terminating ] for character class at offset 15 in
-----------------

i think problem due to this error
please help me out
thanks
san
san26 12 Jul, 2007
but im stilling getting email but empty..as before ??
thank
san
Max_admin 12 Jul, 2007
Hi San,

This seems to be some unclosed bracket inside your HTML, plz double heck them all, I would help with this but have a very slow connection here out of town, hopefully will get back to normal soon!

Keep us updated on the status of it and double check all brackets please.

Cheers

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
san26 12 Jul, 2007
hi Max,
i have seen it.. but not found any open bracket,,

please help me out
thanks
san
GreyHead 12 Jul, 2007
Hi San,

I've had a go at re-creating your form and I think I have got it working. I found a couple of little bugs in the code for dealing with arrays in templates.

In chronocontact.php please find this code starting at line 152
foreach ($matches[0] as $match)
{
  $new_match = preg_replace('/name=("|\')/i', '', $match);
  $new_match2 = preg_replace('/("|\')/', '', $new_match);
  $name = preg_replace('/name=("|\')/', '', $new_match2);
  $emailbodytemplate = $rows[0]->emailtemplate;
  $pattern = '/({)'.$name.'(})/';
  if(strpos($name, '[]')){
    $name = str_replace('[]', '', $name);
  }
  if(is_array($_POST[$name])) {$_POST[$name] = implode(", ", $_POST[$name]);} else {$name_array = $_POST[$name];}
  $replace = $name_array;
  if ($i > 0) {
    $emailbodytemplate =  html_message;
  }
  $html_message = preg_replace($pattern, $replace, $emailbodytemplate);
$i++;
}
and replace it with this code
foreach ($matches[0] as $match)
{
  $new_match = preg_replace('/name=("|\')/i', '', $match);
  $new_match2 = preg_replace('/("|\')/', '', $new_match);
  $name = preg_replace('/name=("|\')/', '', $new_match2);
  $emailbodytemplate = $rows[0]->emailtemplate;
  if(strpos($name, '[]')){
    $name = str_replace('[]', '', $name);
  }
  $pattern = "/\\{".$name."\\}/";
  if(is_array($_POST[$name])) {$name_array = implode(", ", $_POST[$name]);} else {$name_array = $_POST[$name];}
  if ($i > 0) {
    $emailbodytemplate = $html_message;
  }
  $html_message = preg_replace($pattern, $name_array, $emailbodytemplate);
  $i++;
}

I've changed a couple of variable names left over from the previous version and the preg_match pattern.

Please will you try this and see if it works for you. Thanks.

Bob

PS This is for v2.2.1 and you should not need the 'implode' code in OnSubmit or AutoGenerate. (If you do then we need to tweak the code some more.)<br><br>Post edited by: GreyHead, at: 2007/07/12 15:31
san26 13 Jul, 2007
hi Bob & MAX

YOU DONE IT.. GREAT.. THANKS A LOT :laugh: :laugh:

ONLY ONE THINK LEFT ??

i want to disply customized message on redirect page..

when email sent, record in database.. form redirect on a other page.. i want to display a customized message on that page..

---------
like " Thanks "user name" ... we will revert back on your email "user email" ...
---------

please fix this problem also.. i will be really very think full..

till now you have done great job..

thanks in advance
GreyHead 13 Jul, 2007
Try using the Form Code : 'On Submit code - after sending email' field and put in something like
Thanks <?php echo $_POST['name']; ?> ... we will revert back on your email <?php echo $_POST['email']; ?>


Bob<br><br>Post edited by: GreyHead, at: 2007/07/12 21:32
san26 13 Jul, 2007
GREAT........ Its done...
thanks a lot..

really great support.
thanks
san
This topic is locked and no more replies can be posted.