Email Notification in Form

4 posts by 2 authors in: Forums > CMS Builder
Last Post: March 4, 2014   (RSS)

Hello,

I am using the email smtp setup that is available now in the CMS settings. I have included the code in one of my forms to send an email when a form is submitted and I have set up a special email template. I am just having two issues. Here is my code:

 // send message

      $placeholders = array(
'user.email'       => $_REQUEST['email'],
'user.fullname'    => $_REQUEST['name'],
'content'          => $_REQUEST['content'],
'contestAdminUrl'  => $GLOBALS['SETTINGS']['adminUrl'] . "?menu=photocontests_new",

      );

       // email admin

      $errors = sendMessage(wsc_emailTemplate_loadFromDB(array(
'template_id'      => 'ADMIN-ENTRY-ADDED',
'placeholders'     => $placeholders,

      )));

      if ($errors) { die("Error sending message: $errors\n\nPlease let us know about this error!"); }

  }

  }  

1). In this url: 'contestAdminUrl'  => $GLOBALS['SETTINGS']['adminUrl'] . "?menu=calendar&action=edit&num=" . mysql_insert_id(),

How do I pull in the record num so it goes directly to the correct entry to edit? 

2). When I tested the form, the email gets sent to me with no issue. The issue is that the fields that I put in the the email template, #user.email# and #user.name# and #content#  are not pulling in any of the data into the sent email. I have included a screen shot of my email template and email that was sent. I have also included my form page with code.

Thanks,

April

Attachments:

emialtemplate.jpg 379K

email.jpg 119K

form.php 19K

Hi April,

There are a couple of small errors that are stopping this form working correctly.

The reason that your place holders are empty is that on line 114 of form.php you have this line:

$_REQUEST      = array();

This is unsetting all of the items in your request array, then on line 121 when you're creating your place holders after the request array has been removed. If you remove the line $_REQUEST = array(); your placeholders should send. 

The second issue is that the mysql_insert_id() contains the num value that was inserted into photocontests_new, but the link in your placeholders is going to the section calendar. I think you just need to change the link to go to photocontests_new on line 125, and the link should work.

$GLOBALS['SETTINGS']['adminUrl'] . "?menu=photocontests_new&action=edit&num=" . mysql_insert_id(),

Let me know if you have any questions.

Cheers!

Greg

Greg Thomas







PHP Programmer - interactivetools.com

Greg,

Thank you for your help.  It is all working except for the url.

I had actually copied and pasted the table name and copied the wrong one (calendar). I am using the correct url now but it returns a 0 instead of the actual id/record number. 

Here is what comes up now:

http://www.charlotteparent.com/cmsadmin/admin.php?menu=photocontests_new&action=edit&num=0

Is there anyway to fix that?

Thanks!

April