Put unique DB identifier into confirmation mail

lordsteve 07 Apr, 2008
Hi,

I am looking for a way to put a unique number for each entry made through a registration form into the confirmation email sent to the user.

Ideally, for the given form, the first person to register with the form would get no. 1, the second no. 2 etc. I presume this could be done relatively easily by grabbing something out of the mysql db with PHP in the confirmation mail template, but I have no experience with accessing a DB in PHP.

This is supposed to be somewhat of a confirmation number that will make it easier to connect a specific user to his record.

Is there a reasonably simple way to do this?

Thanks
-ls
Max_admin 08 Apr, 2008
Hi LordSteve,

You will need to hack the plugin code itself, after the row is stored you can get the user id with the $row->id, you can include this in the confirmation email text somehow!

If you can't get it done then post again here and I will try to show you some code example!🙂

Cheers

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
lordsteve 08 Apr, 2008
Hi Max,

Thanks for the quick reply. I tried adding the following just before line 310:

$html_message = str_replace("{rowid}", $rows->id, $html_message);


Now I get errors when submitting the form:

Warning: reset() [function.reset]: Passed variable is not an array or object in /dev1/includes/joomla.php on line 3992

Warning: Variable passed to each() is not an array or object in /dev1/includes/joomla.php on line 3994

Any ideas? My limited understanding of PHP tells me what I did should work, but apparently it doesn't🙂

Thanks
-ls
Max_admin 08 Apr, 2008
Hi Steve,

By the "confirmation email" you meant the one sent by the plugin or by Chronoforms ? you have Joomla 1.0 or J1.5 ? what was the file you hacked ?

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
lordsteve 08 Apr, 2008
Sorry was a bit unclear🙂

I'm not using a plugin. By "registration" I meant registration for a conference -- using just Chronoforms. So I edited the chronocontact.php file.

So, by confirmation mail I mean the one sent by chronoforms. The mail went out fine actually, regardless of the error message (the {rowid} I had inserted was just replaced with emptiness however).

I'm using J1.0.x.<br><br>Post edited by: lordsteve, at: 2008/04/08 15:39
Max_admin 08 Apr, 2008
mmm, got it, the DB data is saved after the email is sent so you are not able to get this unique db record without making some hack in the code itself too, plz try this :

at the end of the autogenerated code, add this line :

global $return_id = $database->insertid();


make your hack like this :

global $return_id;
$html_message = str_replace("{rowid}", $return_id, $html_message);


now, get this block of code :

if ( !empty($rows[0]->autogenerated) ) {
					eval( "?>".$rows[0]->autogenerated );
				}


above :


$email_sent = mosMail($from, $fromname, $recipient, $subject, $html_message, true,
	       $ccemails, $bccemails, $attachments, $replyto_email, $replyto_name );


in chronocontact.php

Let me know how this will go!

Cheers

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
lordsteve 08 Apr, 2008
did what you suggested, but now I get in addition to the errors from before:

Parse error: syntax error, unexpected '=', expecting ',' or ';' in /dev1/components/com_chronocontact/chronocontact.php(466) : eval()'d code on line 11

466 is the line I moved this to:
eval( "?>".$rows[0]->autogenerated );


-ls
Max_admin 08 Apr, 2008
Ok, lets do this :

make this line :

 global $return_id = $database->insertid();


as :

 global $return_id;

 $return_id = $database->insertid();
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
lordsteve 08 Apr, 2008
no luck😟

but i'm back to only seeing error messages about includes/joomla.php

do you know what those mean? i have a feeling that i might have messed up the database with my initial trying around, is that possible? i'll export my form and make a clean joomla install to try again.

thanks anyway for the help so far..
-ls
Max_admin 09 Apr, 2008
K, let me know what happnes!

Cheers

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
RichardGG 10 Apr, 2008
Its to do with a missing parameter - I had exactly the same problem. When creating/editing a form you need to make sure you pair up the From Email and From Name fields. This probably also applies to Reply To Email and Reply To Name. I found I had populated the From Email but not the Name. Once the name was filled in it worked fine.

Richard
Max_admin 10 Apr, 2008
Hi Richard,

Thanks for the info but I think this post is off topic, may be you wanted to post it somewhere else and there was some error ?

Thanks

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
lordsteve 10 Apr, 2008
No no, Richard was straight on topic. I think he is referring to these two error messages:

Warning: reset() [function.reset]: Passed variable is not an array or object in /dev1/includes/joomla.php on line 3992

Warning: Variable passed to each() is not an array or object in /dev1/includes/joomla.php on line 3994

I checked in the form settings, and indeed, I had set a Reply-To email address but no Reply-To name. Set a name, tried submitting, and now I don't get these errors anymore. It's still somewhat odd because I had that Reply-To name field empty from the start, but the errors appeared sometime later..

EDIT: Actually I might have added the reply-to later, so in the beginning both reply-to fields were empty, thus no error (?). In any case this seems to be a bug in the software.

Anyway, thanks a lot for that tip Richard!

Still, the problem with the rowid remains. The confirmation email just contains an empty nothing ("") where the rowid should be inserted. But no errors. I'm busy with some other things right now and will try to fix the form in a few days (if you have any other idea what might be going wrong Max I would be grateful)

Cheers
-ls<br><br>Post edited by: lordsteve, at: 2008/04/10 11:39
RichardGG 10 Apr, 2008
Lordsteve

Glad I could be of help. You are right about me responding to the Warning messages as this is where I arrived when searching the forum for the problem I was seeing. Its only because I used the DEBUG mode that I realised it was working in CF and a Joomla component was in error.

I don't think its a bug in CF more like Joomla itself. As the error reporting says its in Joomla.php and if you look at the code its obviously the empty array it can't deal with correctly. I think I use PHP 4.4.6 - maybe later versions don't suffer from the same bug.

Richard
lordsteve 10 Apr, 2008
I'm using PHP 5.2.3 so it seems it isn't a PHP4 problem.
GreyHead 11 Apr, 2008
Hi LordSteve,

The error comes up in the Joomla mail functions. I don't remember the exact sequence and can't look it up here but from memory Joomla checks to see if the values are there and if they aren't tries to use the values set in site config. I think that partial entries trip up this sequence somehow.

Bob
Max_admin 11 Apr, 2008
Hi Steve, please dont add any reply to name or email and test the form normally without any hacks, do you get errors ?

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
lordsteve 30 Apr, 2008
Sorry for taking so long, I was busy with other things.

Without the hack there seem to be no problems. Don't know why the hack caused the problems though since there seems to be no direct connection.

Anyway, the people I was going to make the form for have decided to ditch Joomla entirely so I no longer have to make this work. Thanks for your help anyway!

-ls
lordsteve 30 Apr, 2008
Sorry for taking so long, I was busy with other things.

Without the hack there seem to be no problems. Don't know why the hack caused the problems though since there seems to be no direct connection.

Anyway, the people I was going to make the form for have decided to ditch Joomla entirely so I no longer have to make this work. Thanks for your help anyway!

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