rvp032582
Posts: 47
|
| Posted: 08/27/2008, 3:03 PM |
|
i have created a form, and when it's submitted i want it to email a link to a recipient that has all the info that was just filled out (display via grid).
i'm guessing i'd need to get the primary ID/key that was just created when filling the form out. how can i get that and pass that in an email
would it be something like:
$ global $users;
$to = "email@email.com";
$subject = "Website Info Request";
$message= "http://www.website.com/view_info.php?theNewID=" . CCDGetfromGet("max(theNewID)", "table_name", "", $DBConnection);
$from = "email@email.com";
$additional_headers = "From: $from\nReply-To: $from\nContent-Type: text/html";
mail ($to, $subject, $message, $additional_headers);
// -------------------------
|
 |
 |
DonP
|
| Posted: 08/27/2008, 3:29 PM |
|
What I did on my form was to take care if the submission using the After
Insert event by simply grabbing the information as it was submitted,
then concatenating it into an email. If the site has usage such that
there is little possibility of multiple submissions at once, you can use
SQL as you said (I would use CCDLookUp()) to grab the latest ID but this
forum (and the php.net site) show the PHP function for how to get it the
"proper" way. I don't recall it off-hand.
However, I would create a variable for the ID:
$messageID = CCDLookUp("MAX(ID)", "table_name", "", $DBConnection);
$message = "http://www.website.com/view_info.php?theNewID=" . $messageID;
Don (DonP)
rvp032582 wrote:
> i have created a form, and when it's submitted i want it to email a link to a
> recipient that has all the info that was just filled out (display via grid).
> i'm guessing i'd need to get the primary ID/key that was just created when
> filling the form out. how can i get that and pass that in an email
>
> would it be something like:
>
> $ global $users;
> $to = "email@email.com";
> $subject = "Website Info Request";
> $message= "http://www.website.com/view_info.php?theNewID=" .
> CCDGetfromGet("max(theNewID)", "table_name", "", $DBConnection);
> $from = "email@email.com";
> $additional_headers = "From: $from\nReply-To: $from\nContent-Type: text/html";
> mail ($to, $subject, $message, $additional_headers);
> // -------------------------
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.yessoftware.com/
>
|
|
|
 |
rvp032582
Posts: 47
|
| Posted: 08/28/2008, 8:36 AM |
|
k thanks. i ended up using this, here's all the code that was used in the after execute insert event
global $users;
global $DBconnection;
$LastID = CCDLookup("max(thenewID)","table_name","thenewlID=".$DBconnection->ToSQL(CCGetFromPost("user_login",""),ccsText),$DBconnection);
$to = "email@email.com";
$subject = "Volunteer Request";
$message= "Please see my volunteer application info at: http://www.website.com/view_inquiry.php?volID=". $LastID;
$from = $Form_Name->EmailField->GetText();
$additional_headers = "From: $from\nReply-To: $from\nContent-Type: text/html";
mail ($to, $subject, $message, $additional_headers);
|
 |
 |
wkempees
Posts: 1679
|
| Posted: 08/28/2008, 3:18 PM |
|
Sorry to butt in, hate to do that but:
You now have one CustomCode added to AfterInsert Event, correct?
RightClick After Iinsert Event, Add Action Dlookup.
Expression: 'last_insert_id()'
Domain: ''
Criteria: ''
Connection: Select it from the dropdownlist <connectionname>
Convert resutl to: Integer (from the list)
Type of Target: Variable (from the list)
Target: LastID
Reclick AfterInsert Event, Dlookup, rightclick MoveUp to position it before your SourceCode block.
Now edit SourceCodeBlock
remove
global $users;
global $DBconnection;
$LastID = CCDLookup("max(thenewID)","table_name","thenewlID=".$DBconnection->ToSQL(CCGetFromPost("user_login",""),ccsText),$DBconnection);
You now have reached two objectives.
1: If your application takes off and gets mass visitor, you will not sent wrong ID.
2: You are doing things the CCS way, using Actions and minimal codeblocks.
(The SendEmail Action is a possibility too, but requires some extra preparing).
Walter
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)
if you liked this info PAYPAL me: http://donate.consultair.eu
|
 |
 |
|