Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Generating an automatic e-mail


skarra

Recommended Posts

hello

 

I receive some files from Steve Kemp that helped me install a system whereby a Member needs to be approved before they can access the shopping cart and is prices. Everything works great.

 

However, I would like to have an email generated that notifies the member that they have been accepted to use the system. The code for the file I have been working on is below. It is back to the stage that it was when Steve sent it to me. I have taken out stuff I've tried.

 

<?php

/*

 $Id: members.php,v 1.1 2002/09/15 20:28:45 wilt Exp $



 osCommerce, Open Source E-Commerce Solutions

 http://www.oscommerce.com



 Copyright (c) 2002 osCommerce



 Released under the GNU General Public License

*/



 require('includes/application_top.php');



 if ($HTTP_GET_VARS['action']) {

   switch ($HTTP_GET_VARS['action']) {

       case 'confirmaccept':

       $query=tep_db_query("update " . TABLE_CUSTOMERS . " set member_level = '1' where customers_id = '" . $HTTP_GET_VARS['cID'] . "'");

       $HTTP_GET_VARS['action'] = '';

       $HTTP_GET_VARS['cID'] = '';

       break;

   }

 }

?>

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">

<html <?php echo HTML_PARAMS; ?>>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">

<title><?php echo TITLE; ?></title>

<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">

<script language="javascript" src="includes/general.js"></script>

</head>

<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="SetFocus();">

<!-- header //-->

<?php require(DIR_WS_INCLUDES . 'header.php'); ?>

<!-- header_eof //-->



<!-- body //-->

<table border="0" width="100%" cellspacing="2" cellpadding="2">

 <tr>

   <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">

<!-- left_navigation //-->

<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>

<!-- left_navigation_eof //-->

   </table></td>

<!-- body_text //-->

   <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">

     <tr>

       <td><table border="0" width="100%" cellspacing="0" cellpadding="0">

         <tr><?php echo tep_draw_form('search', FILENAME_CUSTOMERS, '', 'get'); ?>

           <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>

           <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', 1, HEADING_IMAGE_HEIGHT); ?></td>

           <td class="smallText" align="right"><?php echo HEADING_TITLE_SEARCH . ' ' . tep_draw_input_field('search'); ?></td>

         </form></tr>

       </table></td>

     </tr>

     <tr>

       <td><table border="0" width="100%" cellspacing="0" cellpadding="0">

         <tr>

           <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">

             <tr class="dataTableHeadingRow">

               <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_LASTNAME; ?></td>

               <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_FIRSTNAME; ?></td>

               <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACCOUNT_CREATED; ?></td>

               <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?> </td>

             </tr>

<?php

   $search = '';

   if ( ($HTTP_GET_VARS['search']) && (tep_not_null($HTTP_GET_VARS['search'])) ) {

     $keywords = tep_db_input(tep_db_prepare_input($HTTP_GET_VARS['search']));

     $search = "where c.customers_lastname like '%" . $keywords . "%' or c.customers_firstname like '%" . $keywords . "%' or c.customers_email_address like '%" . $keywords . "' and member_level = '0'";

   }

   if ($search =='') $search = "where member_level = '0'"; 

   $customers_query_raw = "select c.customers_id, c.customers_lastname, c.customers_firstname, c.customers_email_address, a.entry_country_id from " . TABLE_CUSTOMERS . " c left join " . TABLE_ADDRESS_BOOK . " a on c.customers_id = a.customers_id and c.customers_default_address_id = a.address_book_id " . $search . " order by c.customers_lastname, c.customers_firstname";

   $customers_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_SEARCH_RESULTS, $customers_query_raw, $customers_query_numrows);

   $customers_query = tep_db_query($customers_query_raw);

   while ($customers = tep_db_fetch_array($customers_query)) {

     $info_query = tep_db_query("select customers_info_date_account_created as date_account_created, customers_info_date_account_last_modified as date_account_last_modified, customers_info_date_of_last_logon as date_last_logon, customers_info_number_of_logons as number_of_logons from " . TABLE_CUSTOMERS_INFO . " where customers_info_id = '" . $customers['customers_id'] . "'");

     $info = tep_db_fetch_array($info_query);



     if (((!$HTTP_GET_VARS['cID']) || (@$HTTP_GET_VARS['cID'] == $customers['customers_id'])) && (!$cInfo)) {

       $country_query = tep_db_query("select countries_name from " . TABLE_COUNTRIES . " where countries_id = '" . $customers['entry_country_id'] . "'");

       $country = tep_db_fetch_array($country_query);



       $reviews_query = tep_db_query("select count(*) as number_of_reviews from " . TABLE_REVIEWS . " where customers_id = '" . $customers['customers_id'] . "'");

       $reviews = tep_db_fetch_array($reviews_query);



       $customer_info = tep_array_merge($country, $info, $reviews);



       $cInfo_array = tep_array_merge($customers, $customer_info);

       $cInfo = new objectInfo($cInfo_array);

     }



     if ( (is_object($cInfo)) && ($customers['customers_id'] == $cInfo->customers_id) ) {

       echo '          <tr class="dataTableRowSelected" onmouseover="this.style.cursor='hand'" onclick="document.location.href='' . tep_href_link(FILENAME_MEMBERS, tep_get_all_get_params(array('cID', 'action')) . 'cID=' . $cInfo->customers_id . '&action=edit') . ''">' . "n";

     } else {

       echo '          <tr class="dataTableRow" onmouseover="this.className='dataTableRowOver';this.style.cursor='hand'" onmouseout="this.className='dataTableRow'" onclick="document.location.href='' . tep_href_link(FILENAME_MEMBERS, tep_get_all_get_params(array('cID')) . 'cID=' . $customers['customers_id']) . ''">' . "n";

     }

?>

               <td class="dataTableContent"><?php echo $customers['customers_lastname']; ?></td>

               <td class="dataTableContent"><?php echo $customers['customers_firstname']; ?></td>

               <td class="dataTableContent" align="right"><?php echo tep_date_short($info['date_account_created']); ?></td>

               <td class="dataTableContent" align="right"><?php if ( (is_object($cInfo)) && ($customers['customers_id'] == $cInfo->customers_id) ) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . tep_href_link(FILENAME_MEMBERS, tep_get_all_get_params(array('cID')) . 'cID=' . $customers['customers_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?> </td>

             </tr>

<?php

   }

?>

             <tr>

               <td colspan="4"><table border="0" width="100%" cellspacing="0" cellpadding="2">

                 <tr>

                   <td class="smallText" valign="top"><?php echo $customers_split->display_count($customers_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $HTTP_GET_VARS['page'], TEXT_DISPLAY_NUMBER_OF_CUSTOMERS); ?></td>

                   <td class="smallText" align="right"><?php echo $customers_split->display_links($customers_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['page'], tep_get_all_get_params(array('page', 'info', 'x', 'y', 'cID'))); ?></td>

                 </tr>

<?php

   if (tep_not_null($HTTP_GET_VARS['search'])) {

?>

                 <tr>

                   <td align="right" colspan="2"><?php echo '<a href="' . tep_href_link(FILENAME_CUSTOMERS) . '">' . tep_image_button('button_reset.gif', IMAGE_RESET) . '</a>'; ?></td>

                 </tr>

<?php

   }

?>

               </table></td>

             </tr>

           </table></td>

<?php

 $heading = array();

 $contents = array();

 switch ($HTTP_GET_VARS['action']) {

   case 'accept':

         $heading[] = array('text' => '<b>' . $cInfo->customers_firstname . ' ' . $cInfo->customers_lastname . '</b>');

         $contents[] = array('text' => '<br>' . TEXT_INFO_COUNTRY . ' ' . $cInfo->countries_name);

         $contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_MEMBERS, tep_get_all_get_params(array('cID', 'action')) . 'cID=' . $cInfo->customers_id . '&action=confirmaccept') . '">' . tep_image_button('button_confirm.gif', IMAGE_CONFIRM) . '</a> <a href="' . tep_href_link(FILENAME_MEMBERS, tep_get_all_get_params(array('cID', 'action')) . 'cID=' . $cInfo->customers_id . '&action=') . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');    

         break;

   default:

     if (is_object($cInfo)) {

         $heading[] = array('text' => '<b>' . $cInfo->customers_firstname . ' ' . $cInfo->customers_lastname . '</b>');

         $contents[] = array('text' => '<br>' . TEXT_INFO_COUNTRY . ' ' . $cInfo->countries_name);

         $contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_MEMBERS, tep_get_all_get_params(array('cID', 'action')) . 'cID=' . $cInfo->customers_id . '&action=accept') . '">' . tep_image_button('button_activate.gif', IMAGE_ACTIVATE) . '</a>');

     }

     break;

 }



 if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) {

   echo '            <td width="25%" valign="top">' . "n";



   $box = new box;

   echo $box->infoBox($heading, $contents);



   echo '            </td>' . "n";

 }

?>

         </tr>

       </table></td>

     </tr>

   </table></td>

<!-- body_text_eof //-->

 </tr>

</table>

<!-- body_eof //-->



<!-- footer //-->

<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>

<!-- footer_eof //-->

<br>

</body>

</html>

<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

 

Sorry about having to include the whole page of code but I am just not sure where I should be working to generate this.

 

Dave

Link to comment
Share on other sites

I understand that this function will generate the email, but I'm not sure where and how to place it. For example does the data base need to be queried again if not what variables are used.

 

Dave

Link to comment
Share on other sites

I can't actually give you access to the file as it is located in a password protected administration area in a working site.

 

Basically what happens is that a list of potential members is generated. It is on this page that the administrator is able to grant approval by selecting the member and clicking on the activate button.

 

What I am trying to do is have the member sent a generated E-mail when the membership is activated.

 

The only data base change was as follows

 

ALTER TABLE `customers` ADD `member_level` INT(5) DEFAULT '0' NOT NULL;

Link to comment
Share on other sites

ok then you put in the onClick="" statement the mail function.

<input type=submit name="reguser" onClick=<?php echo tep_mail();?> >

just put your values in for the mail. you will probably have to do a query on the database first to get the correct user information. probably put a checkbox next to their name and a onClick="" statement

<input type=checkbox name="getinfo" onClick=<?php echo tep_db_query();?>

and put the correct info into it. hope this helps :lol:

Link to comment
Share on other sites

I got it working yesterday afternoon. Thank you for your help.

 

The method that I used was-

 

Replace

 

case 'accept':

$heading[] = array('text' => '<b>' . $cInfo->customers_firstname . ' ' . $cInfo->customers_lastname . '</b>');

$contents[] = array('text' => '<br>' . TEXT_INFO_COUNTRY . ' ' . $cInfo->countries_name);

$contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_MEMBERS, tep_get_all_get_params(array('cID', 'action')) . 'cID=' . $cInfo->customers_id . '&action=confirmaccept') . '">' . tep_image_button('button_confirm.gif', IMAGE_CONFIRM) . '</a> <a href="' . tep_href_link(FILENAME_MEMBERS, tep_get_all_get_params(array('cID', 'action')) . 'cID=' . $cInfo->customers_id . '&action=') . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');

 

With this

 

case 'accept':

$email = STORE_NAME . "n" . EMAIL_SEPARATOR . "n" . EMAIL_TEXT_CONFIRM . "nn" . EMAIL_CONTACT . "nn" . EMAIL_WARNING . "nn";

$heading[] = array('text' => '<b>' . $cInfo->customers_firstname . ' ' . $cInfo->customers_lastname . '</b>');

$contents[] = array('text' => '<br>' . TEXT_INFO_COUNTRY . ' ' . $cInfo->countries_name);

$contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_MEMBERS, tep_get_all_get_params(array('cID', 'action')) . 'cID=' . $cInfo->customers_id . '&action=confirmaccept') . '" onclick="' .tep_mail($cInfo->customers_name, $cInfo->customers_email_address, EMAIL_TEXT_SUBJECT, nl2br($email), STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, '') . '">' . tep_image_button('button_confirm.gif', IMAGE_CONFIRM) . '</a> <a href="' . tep_href_link(FILENAME_MEMBERS, tep_get_all_get_params(array('cID', 'action')) . 'cID=' . $cInfo->customers_id . '&action=') . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');

Dave

Link to comment
Share on other sites

  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...