Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Can Anyone Work This One Out


qorn

Recommended Posts

I have a script which will allow customers to add there email address and signup to the newsletter from the index page without having to create an account - Complements of Tim Boughton.

Can anyone help me to get this running and maybe poss combine the 2 files as Tim said.

I cannot get it working, this is my email i recived from him:-

Dave

 

 

 

Sorry for slow response.

 

 

 

See attached files. It's a bit complex because I use the "one template" contribution to change the structure of my files. You'll need to rename the files and put them back together if you don't.

 

 

 

box_quick_signup.php should be quick_signup.php under boxes and is the box itself

 

top_quick_signup.php and body_quick_signup.php, you could put back together into a single file which is the page which receives the POST from the box and handles adding the new request.

 

 

 

I think you may also have to make some changes elsewhere to cope with the fact that osCommerce doesn't normally expect a "user entry" to only have an email address.

 

 

 

Hope this helps

 

Tim

 

The script is

box_quick_signup.php

<?php
/*
 $Id: quick_signup.php,v 1.1 2003/06/22 08:19:56 Tim Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2001 osCommerce

 Released under the GNU General Public License
*/
?>
<!-- search //-->
         <tr>
           <td>
<?php
 $info_box_contents = array();
 $info_box_contents[] = array('align' => 'left',
                              'text'  => BOX_HEADING_QUICK_SIGNUP
                             );
 new infoBoxHeading($info_box_contents, false, false);

 $hide = tep_hide_session_id();
 $info_box_contents = array();
 $info_box_contents[] = array('form'  => '<form name="quick_signup" method="get" action="' . tep_href_link(FILENAME_QUICK_SIGNUP, '', 'SSL', false) . '">',
                              'align' => 'center',
                              'text'  => $hide . '<input type="hidden" name="pageID" value="' . FILENAME_QUICK_SIGNUP. '"><input type="text" name="email_address" size="10" maxlength="255" value="" style="width: ' . (BOX_WIDTH-30) . 'px"> ' . tep_image_submit('button_small_continue.gif', BOX_HEADING_QUICK_SIGNUP) . '<br>' . BOX_QUICK_SIGNUP_TEXT . '<br>'
                             );
 new infoBox($info_box_contents);
?>
           </td>
         </tr>
<!-- search_eof //-->

 

top_quick_signup.php

<?php
/*
 $Id: quick_signup.php,v 1.1 2003/06/22 08:20:07 Tim Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2002 osCommerce

 Released under the GNU General Public License
*/
global $insert_java;
$insert_java = 'false';

 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_QUICK_SIGNUP);
 
 $action = "process";
 
 if ( ($HTTP_GET_VARS['email_address'] != "") || (strlen($HTTP_GET_VARS['email_address']) > 0 )) {
   // Actually insert the email address into the table
$email_address = tep_db_prepare_input($HTTP_GET_VARS['email_address']);
$newsletter = 1; // subscribed
$error = false; // reset error flag

 if (strlen($email_address) < ENTRY_EMAIL_ADDRESS_MIN_LENGTH) {
       $error = true;
       $entry_email_address_error = true;
  } else {
    $entry_email_address_error = false;
  }

  if (!tep_validate_email($email_address)) {
    $error = true;
    $entry_email_address_check_error = true;
  } else {
    $entry_email_address_check_error = false;
  }
  
  $check_email = tep_db_query("select customers_email_address from " . TABLE_CUSTOMERS . " where customers_email_address = '" . tep_db_input($email_address) . "' and customers_id <> '" . tep_db_input($customer_id) . "'");
  if (tep_db_num_rows($check_email)) {
    $error = true;
    $entry_email_address_exists = true;
  } else {
    $entry_email_address_exists = false;
  }
  
  if ($error == true) {
    $processed = true;

    $breadcrumb->add(NAVBAR_TITLE2);
 
   } else {
	 $sql_data_array = array('customers_email_address' => $email_address,
                             'customers_newsletter' => $newsletter,
      	 'customers_default_address_id' => 0); //no address
 
     tep_db_perform(TABLE_CUSTOMERS, $sql_data_array);
 
     $customer_id = tep_db_insert_id();
	 
	 // then show confirmation page
	 $action = "confirm";
   }

 } else {
	 if ($HTTP_GET_VARS['action'] == "process") {
   $error = true;
   $entry_email_address_error = true;
	 }
 $breadcrumb->add(NAVBAR_TITLE1, tep_href_link(FILENAME_QUICK_SIGNUP, '', 'NONSSL'));

 }
?>

 

body_quick_signup.php

<?php
/*
 $Id: quick_signup.php,v 1.1 2003/06/22 08:20:06 Tim Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2002 osCommerce

 Released under the GNU General Public License
*/
?>

<!-- body_text //-->
  <td width="100%" valign="top">
  <form name="quick_signup" method="get" <?php echo 'action="' . tep_href_link(FILENAME_QUICK_SIGNUP, '', 'SSL') . '"'; ?> onSubmit="return check_form();">
  <input type="hidden" name="action" value="process">
  <input type="hidden" name="pageID" value="<?php echo FILENAME_QUICK_SIGNUP?>">
<table border="0" width="100%" cellspacing="0" cellpadding="0">
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
           <td class="pageHeading" align="right"><?php //echo tep_image(DIR_WS_IMAGES . 'table_background_browse.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
         </tr>
       </table></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
     <tr>
       <td>
   <tr>
<table border="0" width="100%" cellspacing="0" cellpadding="2">
  <tr>
    <td class="main"><?php if ($action == 'confirm') {
       echo TEXT_CONFIRM;
    	 } else {
       if ($entry_email_address_exists) {
      	 echo TEXT_IF_MEMBER;
       } else {
      	 echo TEXT_WHY_SIGNUP;
       }
    	 } ?></td>
  </tr>
  <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
  <?php if ($action != 'confirm') { ?>
  <tr>
    <td class="main"><table border="0" width="100%" cellspacing="0" cellpadding="2" class="formArea">
      <tr>
        <td class="main"><table border="0" cellspacing="0" cellpadding="2">

          <tr>
           <td class="main"> <?php echo ENTRY_EMAIL_ADDRESS; ?></td>
           <td class="main"> 
<?php

 if ($error) {
   if ($entry_email_address_error) {
     echo tep_draw_input_field('email_address') . ' ' . ENTRY_EMAIL_ADDRESS_ERROR;
   } elseif ($entry_email_address_check_error) {
     echo tep_draw_input_field('email_address') . ' ' . ENTRY_EMAIL_ADDRESS_CHECK_ERROR;
   } elseif ($entry_email_address_exists) {
     echo tep_draw_input_field('email_address') . ' ' . ENTRY_EMAIL_ADDRESS_ERROR_EXISTS;
   } else {
     echo $email_address . tep_draw_hidden_field('email_address');
   }
 } else {
   echo tep_draw_input_field('email_address', '') . ' ' . ENTRY_EMAIL_ADDRESS_TEXT;
 }
?></td>
         </tr>
   </tr>
       </table></td>
     </tr>
   </table></td>
 </tr>
 <?php } ?>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
     <tr>
  <td>
   <table width="100%" border="0" cellspacing="0" cellpadding="0">
   <tr>
        <td class="main" align="left"><?php if ($action != 'confirm') {
          	 echo '<a href="' . tep_href_link(FILENAME_DEFAULT, tep_get_all_get_params(array('sort', 'page', 'x', 'y')), 'NONSSL', true, false) . '">' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>'; 
           }?></td>
        <td align="right" class="main"><?php if ($action != 'confirm') {
          	 echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); 
            } else {
             echo '<a href="' . tep_href_link(FILENAME_DEFAULT, tep_get_all_get_params(array('sort', 'page', 'x', 'y')), 'NONSSL', true, false) . '">' . tep_image_button('button_continue.gif', IMAGE_BUTTON_CONTINUE) . '</a>'; 
            }?></td>
      </tr>
  </table>
  </td>
  </tr>
   </table></form></td>
<!-- body_text_eof //-->
   <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="1" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- right_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>
<!-- right_navigation_eof //-->
   </table></td>

 

Kind Regards and Thank you for all your help

 

Dave

Link to comment
Share on other sites

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...