combine login/create account in one page

combine login/create account in one page

Postby steve_s on Sun Mar 28, 2010 12:33 pm

Hi All

replace code in login.php with code below
Code: Select all
<?php

  require_once ( 'includes/application_top.php' );

// redirect the customer to a friendly cookie-must-be-enabled page if cookies are disabled (or the session has not started)
  if ($session_started == false) {
    tep_redirect(tep_href_link(FILENAME_COOKIE_USAGE));
  }

  @include_once ( DIR_WS_LANGUAGES . $language . '/' . FILENAME_LOGIN);

   if ( true === defined('PHPBB_INTEGRATION') && 'Enabled' == PHPBB_INTEGRATION ) {
      require_once ( DIR_WS_FUNCTIONS . 'phpbb.php' );
   }


   if ( false === empty($_GET['activate_account']) && true === defined('PHPBB_INTEGRATION') ) {
      if ( true === defined('PHPBB_ACCOUNT_ACTIVATION') && 'Enabled' == PHPBB_INTEGRATION && 'User' == PHPBB_ACCOUNT_ACTIVATION ) {
         $activated = tep_account_activate($_GET['activate_account']);
         if ( true === $activated ) {
            $messageStack->add('activated', TEXT_ACCOUNT_ACTIVATED, 'success');
         } else {
            $messageStack->add('activated', TEXT_ACCOUNT_NOT_ACTIVATED, 'error');
         }
      }
   }

   # PASSWORD CHANGED?
   if ( true == tep_session_is_registered('password_sent') ) {
      tep_session_unregister('password_sent');
      $messageStack->add('password_sent', PASSWORD_SENT_SUCCESS, 'success');
   }

   if ( 'On' == CAPTCHA_LOGIN ) {
      require_once ( DIR_WS_FUNCTIONS. 'captcha.php' );
      $show_captcha = ( 'Logic' == CAPTCHA_LOGIN_TYPE ? tep_show_login_captcha_by_ip() : true );
   }



  $error = false;
  if($_GET['login'] == 'fail') {
    $fail_reason = (!empty($_GET['reason'])) ? urldecode($_GET['reason']): TEXT_LOGIN_ERROR;
    $messageStack->add('login', $fail_reason);
    $error = true;
  }
  if (isset($_GET['action']) && ($_GET['action'] == 'process')) {
    $email_address = tep_db_input($_POST['email_address']);
    $password = tep_db_input($_POST['password']);

   if ( 'On' == CAPTCHA_LOGIN ) {
      tep_login_attempt($email_address, $password);
      $securitycode_error = false;
      if ( true === $show_captcha  )  {
         $security_entered = urlsafe_b64encode(CAP_RC4(CAPTCHA_ENCRYPTION_KEY, (strtoupper(tep_db_input($_POST['security'])))));
         if ( true === empty($security_entered) || $security_entered != $_SESSION['captcha_secure_code'] ) {
                $securitycode_error = true;
         }
      }
   }

   $user_id_sql = ( true === defined('PHPBB_INTEGRATION') && 'Enabled' == PHPBB_INTEGRATION ? " OR customers_user_id = '{$email_address}'" : '' );
   $check_customer_query_sql = "select customers_id, customers_firstname, customers_group_id, customers_password, customers_email_address, customers_user_id, customers_default_address_id from " . TABLE_CUSTOMERS . " where customers_email_address = '{$email_address}' $user_id_sql";
   $check_customer_query = tep_db_query($check_customer_query_sql);

   $valid_user = tep_db_num_rows($check_customer_query);
   if  ( false == $valid_user ) {
      $phpbb_account_created = false;
      if ( true === defined('PHPBB_INTEGRATION') && 'Enabled' == PHPBB_INTEGRATION ) {
         $valid_user = phpbb_create_account($email_address, $password);
         if ( true === $valid_user ) {
            $check_customer_query = tep_db_query($check_customer_query_sql);
            $phpbb_account_created = true;
         }
      }
   }

   if  ( false == $valid_user ) {
         $error = true;
   } else {
      $check_customer = tep_db_fetch_array($check_customer_query);

      if ( false == tep_validate_password($password, $check_customer['customers_password'])) {
         $error = true;
      } elseif ( 'On' == CAPTCHA_LOGIN && $securitycode_error == true ) {
         $error = true;
      } else {

         if ( 'On' == CAPTCHA_LOGIN ) {
            tep_login_attempt_success();
         }


        if ( 'True' == SESSION_RECREATE ) {
          tep_session_recreate();
          $SID=tep_session_name() . '=' . tep_session_id();
        }

        $check_country_query = tep_db_query("select entry_country_id, entry_zone_id from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$check_customer['customers_id'] . "' and address_book_id = '" . (int)$check_customer['customers_default_address_id'] . "'");
        $check_country = tep_db_fetch_array($check_country_query);

        $customer_id = $check_customer['customers_id'];
        $customer_default_address_id = $check_customer['customers_default_address_id'];
        $customer_first_name = $check_customer['customers_firstname'];

        if ($_GET['skip'] == 'true' && $email_address == SPPC_TOGGLE_LOGIN_PASSWORD && isset($_POST['new_customers_group_id']))  {
          $sppc_customer_group_id = tep_db_input($_POST['new_customers_group_id']);
          $check_customer_group_tax = tep_db_query("select customers_group_show_tax, customers_group_tax_exempt from " . TABLE_CUSTOMERS_GROUPS . " where customers_group_id = '" .(int)$_POST['new_customers_group_id'] . "'");
        } else {
          $sppc_customer_group_id = $check_customer['customers_group_id'];
          $check_customer_group_tax = tep_db_query("select customers_group_show_tax, customers_group_tax_exempt from " . TABLE_CUSTOMERS_GROUPS . " where customers_group_id = '" .(int)$check_customer['customers_group_id'] . "'");
        }
        $customer_group_tax = tep_db_fetch_array($check_customer_group_tax);
        $sppc_customer_group_show_tax = (int)$customer_group_tax['customers_group_show_tax'];
        $sppc_customer_group_tax_exempt = (int)$customer_group_tax['customers_group_tax_exempt'];

        $customer_country_id = $check_country['entry_country_id'];
        $customer_zone_id = $check_country['entry_zone_id'];
        tep_session_register('customer_id');
        tep_session_register('customer_default_address_id');
        tep_session_register('customer_first_name');

        tep_session_register('sppc_customer_group_id');
        tep_session_register('sppc_customer_group_show_tax');
        tep_session_register('sppc_customer_group_tax_exempt');

        tep_session_register('customer_country_id');
        tep_session_register('customer_zone_id');

        tep_db_query("update " . TABLE_CUSTOMERS_INFO . " set customers_info_date_of_last_logon = now(), customers_info_number_of_logons = customers_info_number_of_logons+1 where customers_info_id = '" . (int)$customer_id . "'");

        if ( true === defined('PHPBB_INTEGRATION') && 'Enabled' == PHPBB_INTEGRATION ) {
           $phpbb_login = phpbb_user_login($customer_id);
           if ( false === empty($phpbb_login['message']) ) {
              $messageStack->add_session('phpbb', $phpbb_login['message'], 'warning');
              tep_redirect(tep_href_link(FILENAME_ACCOUNT));
           }
        }


        if (tep_session_is_registered('floating_gv_code')) {
          $gv_query = tep_db_query("SELECT c.coupon_id, c.coupon_amount, IF(rt.coupon_id>0, 'true', 'false') AS redeemed FROM ". TABLE_COUPONS ." c LEFT JOIN ". TABLE_COUPON_REDEEM_TRACK." rt USING(coupon_id), ". TABLE_COUPON_EMAIL_TRACK ." et WHERE c.coupon_code = '". $floating_gv_code ."' AND c.coupon_id = et.coupon_id");
          // check if coupon exist
          if (tep_db_num_rows($gv_query) >0) {
            $coupon = tep_db_fetch_array($gv_query);
            // check if coupon_id exist and coupon not redeemed
            if($coupon['coupon_id']>0 && $coupon['redeemed'] == 'false') {
              tep_session_unregister('floating_gv_code' );
              $gv_query = tep_db_query("insert into  " . TABLE_COUPON_REDEEM_TRACK . " (coupon_id, customer_id, redeem_date, redeem_ip) values ('" . $coupon['coupon_id'] . "', '" . $customer_id . "', now(),'" . $REMOTE_ADDR . "')");
              $gv_update = tep_db_query("update " . TABLE_COUPONS . " set coupon_active = 'N' where coupon_id = '" . $coupon['coupon_id'] . "'");
              tep_gv_account_update($customer_id, $coupon['coupon_id']);
            }
          }
        }

      // restore cart contents
      $check_basket_before = $_SESSION['cart']->count_contents();
      $cart->restore_contents();
      $check_basket_after = $cart->count_contents();
      if ( ($check_basket_before != $check_basket_after ) && 0 < $check_basket_before && 0 < $check_basket_after ) {
         $messageStack->add_session('shopping_cart', WARNING_SHOPPING_CART_COMBINED, 'warning');
         tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));
      }

      $wishList->restore_wishlist();
      
        $check_password_requests_query_sql = "
                             SELECT
                                password_requests_id,
                                password_new,
                                customers_email
                             FROM
                                " . TABLE_PASSWORD_REQUESTS . "
                             WHERE
                                customers_email = '$email_address'
                                AND password_new = '$password'
                                ";
         $check_password_requests_query = tep_db_query($check_password_requests_query_sql);
         if ( 0 < tep_db_num_rows($check_password_requests_query) ) { # OLD PASSWORD
            //redirect to change password, show message.
            if ( false == tep_session_is_registered('password_change') ) {
               tep_session_register('password_change');
            }
            tep_redirect(tep_href_link(FILENAME_ACCOUNT_PASSWORD, '', 'SSL'));
      } else {
         //delete record
         tep_db_query("DELETE FROM " . TABLE_PASSWORD_REQUESTS . " WHERE customers_email = '$email_address' LIMIT 1");
      }

      if ( true === $phpbb_account_created ) {
         $messageStack->add_session('forum_new_account', TEXT_FORUM_ACCOUNT_CREATED, 'warning');
         tep_redirect(tep_href_link(FILENAME_ACCOUNT_EDIT));
      }

        if (sizeof($navigation->snapshot) > 0 && '' != $navigation->snapshot['page']) {
          $origin_href = tep_href_link($navigation->snapshot['page'], tep_array_to_string($navigation->snapshot['get'], array(tep_session_name())), $navigation->snapshot['mode']);
          $navigation->clear_snapshot();
          tep_redirect($origin_href);
        } elseif ( false === empty($_POST['continue_to']) ) {
      $continue_to_url = base64_decode($_POST['continue_to']);
      if ( false != $continue_to_url ) {
         tep_redirect(tep_href_link($continue_to_url));
      } else {
         tep_redirect(tep_href_link(FILENAME_DEFAULT));
      }
        } else {
          tep_redirect(tep_href_link(FILENAME_DEFAULT));
        }
      }
    }
  }

     if ( 'On' == CAPTCHA_LOGIN && true === $show_captcha  ) {
         $smarty->assign('INPUT_CAPTCHA', tep_draw_input_field('security', '', 'class="inputNormal" size="6" id="captcha_security"'));
         tep_session_register('captcha_secure_code');
         $generated_captcha_key = tep_create_random_value(CAPTCHA_CHARS_NUM);
         $captcha_secure_code = urlsafe_b64encode(CAP_RC4(CAPTCHA_ENCRYPTION_KEY, (strtoupper(tep_db_input($generated_captcha_key)))));
         $smarty->assign('CAPTCHA_IMAGE', '<img src="'.DIR_WS_IMAGES.'captcha.php?code='.$captcha_secure_code.'" border="0" style="border:1px #CCCCCC dotted; margin:5px;" id="id_captcha" />');
   }

  if ( true === $error ) {
     if ( true === $show_captcha ) {
        if ( true != $securitycode_error ) {
         $messageStack->add('login', TEXT_LOGIN_ERROR);
        } else {
           $messageStack->add('contact_security', ERROR_SECURITY);
        }
     } else {
        $messageStack->add('login', TEXT_LOGIN_ERROR);
     }
  }


  $smarty->assign('messagestack', $messageStack->get_messages());


  $content = CONTENT_LOGIN;
  $smarty->assign('login_active', ' class="active"');


   $smarty->assign('HEADER_TITLE', HEADING_TITLE);

   $smarty->assign('ENTRY_PASSWORD', ENTRY_PASSWORD);
   $default_email_address = ( false === empty($_GET['email_address']) ? tep_db_input($_GET['email_address']) : '' );
   $smarty->assign('INPUT_EMAIL_ADDRESS', tep_draw_input_field('email_address', $default_email_address, 'class="inputNormal" id="email_address"'));
   $smarty->assign('INPUT_PASSWORD', tep_draw_password_field('password', '', 'class="inputNormal" id="password"'));

   $smarty->assign('FILENAME_PASSWORD_FORGOTTEN', tep_href_link(FILENAME_PASSWORD_FORGOTTEN, '', 'SSL'));
   $smarty->assign('URL_CREATE_ACCOUNT', tep_href_link(FILENAME_CREATE_ACCOUNT, '', 'SSL'));

   // ** GOOGLE CHECKOUT **
    // Checks if the Google Checkout payment module has been enabled and if so
    // includes gcheckout.php to add the Checkout button to the page
    if ( true == defined('MODULE_PAYMENT_GOOGLECHECKOUT_STATUS') && 'True' == MODULE_PAYMENT_GOOGLECHECKOUT_STATUS ) {
      include_once('googlecheckout/gcheckout.php');
    }
    // ** END GOOGLE CHECKOUT **

   //---PayPal WPP Modification START ---//
   $tep_paypal_wpp_ep_button = tep_paypal_wpp_ep_button(FILENAME_SHOPPING_CART);
   //---PayPal WPP Modification END ---//
   if( false !== $tep_paypal_wpp_ep_button ) {
      $smarty->assign('tep_paypal_wpp_ep_button', $tep_paypal_wpp_ep_button);
   }


   require_once ( DIR_WS_INCLUDES . 'meta_tags.php' );


   $page_content = tep_draw_form('login', tep_href_link(FILENAME_LOGIN, 'action=process', 'SSL'));
   //$page_content .= tep_draw_hidden_field('set_captcha', $captcha);
   if ( false === empty($_GET['continue_to']) ) {
      $page_content .= tep_draw_hidden_field('continue_to', tep_db_input($_GET['continue_to']));
   }

      $page_content .= $smarty->fetch('login.tpl' );
        $page_content .= '</form>';

           $smarty->assign('INPUT_EMAIL_ADDRESS', tep_draw_input_field('email_address', '', 'id="email_address" class="'.$class.'"'));

   if ( true === defined('PHPBB_INTEGRATION') && 'Enabled' == PHPBB_INTEGRATION ) {
      $class = ( true === $error_type['username'] ? 'inputNormalError' : 'inputNormal' );
      $smarty->assign('INPUT_USERNAME', tep_draw_input_field('username', '', 'id="username" class="'.$class.'"'));
      $forum_account_1 = ( '1' == $_POST['forum_account'] || false === isset($_POST['forum_account']) ? true : false );
      $forum_account_0 = ( '0' == $_POST['forum_account'] ? true : false );
      $smarty->assign('INPUT_FORUM_ACCOUNT', tep_draw_radio_field('forum_account', '1', $forum_account_1, 'id="forum_account_1" onclick="document.getElementById(\'username\').disabled=false;"') . '&nbsp;&nbsp;' . TEXT_YES . '&nbsp;&nbsp;' . tep_draw_radio_field('forum_account', '0', $forum_account_0, 'id="forum_account_0" onclick="document.getElementById(\'username\').disabled=true;"') . '&nbsp;&nbsp;' . TEXT_NO );
   }




   @include_once ( DIR_WS_LANGUAGES . $language . '/' . FILENAME_CREATE_ACCOUNT);
   $class = ( true === $error_type['password'] ? 'inputNormalError' : 'inputNormal' );
   $smarty->assign('INPUT_PASSWORD', tep_draw_password_field('password', $password, 'id="password" class="'.$class.'"'));
   $smarty->assign('INPUT_PASSWORD_CONFIRMATION', tep_draw_password_field('confirmation', $confirmation, 'id="confirmation" class="'.$class.'"'));


   if ( 'true' == ACCOUNT_GENDER ) {
      $class = ( true === $error_type['gender'] ? ' class="inputNormalError"' : '' );
      $smarty->assign('INPUT_ENTRY_GENDER', '<span'.$class.'>'.tep_draw_radio_field('gender', 'm', false, 'id="gender_m"') . '&nbsp;&nbsp;' . MALE . '&nbsp;&nbsp;' . tep_draw_radio_field('gender', 'f', false, 'id="gender_f"') . '&nbsp;&nbsp;' . FEMALE . '</span>' );
   }

   $class = ( true === $error_type['firstname'] ? 'inputNormalError' : 'inputNormal' );
   $smarty->assign('INPUT_FIRST_NAME', tep_draw_input_field('firstname', '','class="'.$class.'" id="firstname"'));

   $class = ( true === $error_type['lastname'] ? 'inputNormalError' : 'inputNormal' );
   $smarty->assign('INPUT_LAST_NAME', tep_draw_input_field('lastname', '','class="'.$class.'" id="lastname"'));


   if ( 'true' == ACCOUNT_DOB ) {
      $class = ( true === $error_type['lastname'] ? 'inputNormalError' : 'inputNormal' );
      $dob_month_values = array();
            array_push($dob_month_values, array('id' => '0','text' => TEXT_EXAMPLE_MONTH));
            for ( $i=1; $i <= 12; $i++ ) {
               $pre = ( $i <= 9 ? '0' : '' );
               array_push($dob_month_values,
                  array('id'=>$pre.$i,'text'=>$pre.$i)
               );
            }
      $class = ( true === $error_type['dob_month'] ? 'inputNormalError' : '' );
      $smarty->assign('INPUT_DATE_OF_BIRTH_MONTH', tep_draw_pull_down_menu('dob_month', $dob_month_values, NULL, 'id="dob_month"'.$class));

      $dob_month_full_values = array();
            array_push($dob_month_full_values, array('id' => '0','text' => TEXT_EXAMPLE_MONTH_FULL));
            for ( $i=1; $i <= 12; $i++ ) {
               $pre = ( $i <= 9 ? '0' : '' );
               array_push($dob_month_full_values,
                  array('id'=>$pre.$i,'text'=>$pre.$i.' - '.getMonth($i))
               );
            }
      $class = ( true === $error_type['dob_month'] ? ' class="inputNormalError"' : '' );
      $smarty->assign('INPUT_DATE_OF_BIRTH_MONTH_FULL', tep_draw_pull_down_menu('dob_month', $dob_month_full_values, NULL, 'id="dob_month"'.$class));


      $dob_month_name_values = array();
            array_push($dob_month_name_values, array('id' => '0','text' => TEXT_EXAMPLE_MONTH_NAME));
            for ( $i=1; $i <= 12; $i++ ) {
               $pre = ( $i <= 9 ? '0' : '' );
               array_push($dob_month_name_values,
                  array('id'=>$pre.$i,'text'=>getMonth($i))
               );
            }
      $class = ( true === $error_type['dob_month'] ? ' class="inputNormalError"' : '' );
      $smarty->assign('INPUT_DATE_OF_BIRTH_MONTH_NAMES', tep_draw_pull_down_menu('dob_month', $dob_month_name_values, NULL, 'id="dob_month"'.$class));


      $dob_day_values = array();
            array_push($dob_day_values, array('id' => '0','text' => TEXT_EXAMPLE_DAY));
            for ( $i=1; $i <= 31; $i++ ) {
               $pre = ( $i <= 9 ? '0' : '' );
               array_push($dob_day_values,
                  array('id'=>$pre.$i,'text'=>$pre.$i)
               );
            }

      $class = ( true === $error_type['dob_day'] ? 'inputNormalError' : '' );
      $smarty->assign('INPUT_DATE_OF_BIRTH_DAY', tep_draw_pull_down_menu('dob_day', $dob_day_values, NULL, 'class="'.$class.'"'));


      $dob_year_values = array();
            $c_year = date('Y' );
            array_push($dob_year_values, array('id' => '0','text' => TEXT_EXAMPLE_YEAR));
            for ( $i=($c_year-10); $i >= ($c_year-90); $i-- ) {
               array_push($dob_year_values,
                  array('id'=>$i,'text'=>$i)
               );
            }
      $class = ( true === $error_type['dob_year'] ? 'inputNormalError' : '' );
      $smarty->assign('INPUT_DATE_OF_BIRTH_YEAR', tep_draw_pull_down_menu('dob_year', $dob_year_values, NULL, 'class="'.$class.'"'));
   }


   if ( 'true' == ACCOUNT_COMPANY ) {
      $class = ( true === $error_type['company'] ? 'inputNormalError' : 'inputNormal' );
      $smarty->assign('INPUT_COMPANY', tep_draw_input_field('company', '','class="'.$class.'" id="company"'));

      $class = ( true === $error_type['company_tax_id'] ? 'inputNormalError' : 'inputNormal' );
      $smarty->assign('INPUT_COMPANY_TAX_ID', tep_draw_input_field('company_tax_id', '','class="'.$class.'" id="company_tax_id"'));
   }

   $class = ( true === $error_type['street_address'] ? 'inputNormalError' : 'inputNormal' );
   $smarty->assign('INPUT_STREET_ADDRESS', tep_draw_input_field('street_address', '', 'class="'.$class.'" id="street_address"'));


   if ( 'true' == ACCOUNT_SUBURB ) {
      $class = ( true === $error_type['suburb'] ? 'inputNormalError' : 'inputNormal' );
      $smarty->assign('INPUT_SUBURB', tep_draw_input_field('suburb', '','class="'.$class.'" id="suburb"'));
   }

   $class = ( true === $error_type['city'] ? 'inputNormalError' : 'inputNormal' );
   $smarty->assign('INPUT_CITY', tep_draw_input_field('city', '', 'class="'.$class.'" id="city"'));


   if ( 'true' == ACCOUNT_STATE ) {
      $class = ( true === $error_type['state'] ? 'inputNormalError' : 'inputNormal' );
      $zones_array = array();
      $zones_query_sql = "
                     SELECT
                        zone_name
                     FROM
                        " . TABLE_ZONES . "
                     WHERE
                        zone_country_id = '$country'
                     ORDER BY zone_name";
      $zones_query = tep_db_query($zones_query_sql);
      if ( 0 < tep_db_num_rows($zones_query) ) {
         $zones_array[] = array('id' => '', 'text' => PULL_DOWN_DEFAULT );
         while ($zones_values = tep_db_fetch_array($zones_query)) {
            $zones_array[] = array('id' => $zones_values['zone_name'], 'text' => $zones_values['zone_name']);
         }
         $output_states = tep_draw_pull_down_menu('state', $zones_array, '', 'class="'.$class.'" id="state"' );
      } else {
         $output_states = tep_draw_input_field('state','','class="'.$class.'" id="state"' );
      }

      $smarty->assign('INPUT_STATE', $output_states);
   }

   $class = ( true === $error_type['postcode'] ? 'inputNormalError' : 'inputNormal' );
   $smarty->assign('INPUT_POST_CODE', tep_draw_input_field('postcode', '', 'class="'.$class.'" id="postcode"'));

   if ( 'true' == ACCOUNT_COUNTRY ) {
      $class = ( true === $error_type['country'] ? 'inputNormalError' : 'inputNormal' );
      $smarty->assign('INPUT_COUNTRY', tep_get_country_list('country', $country,'onchange="return refresh_form(\'create_account\');" id="country"'));
   } else {
      $smarty->assign('INPUT_COUNTRY', tep_draw_hidden_field('country', STORE_COUNTRY));
   }

   if ( '223' == $country ) { # check if US
   $class = ( true === $error_type['phoneAreaCode'] ? 'inputNormalError' : 'inputNormal' );
   $phoneAreaCode = tep_draw_input_field('phoneAreaCode', $phone1, 'id="phone" class="'.$class.'" size="3" onselect="stopAutoTab();" maxlength="3" style="width:35px;" onkeypress="AutoTabEdit(this,3,event);" onclick="this.value=\'\';"' );
   $class = ( true === $error_type['phonePrefix'] ? 'inputNormalError' : 'inputNormal' );
   $phonePrefix = tep_draw_input_field('phonePrefix', $phone2, 'id="phonePrefix" class="'.$class.'" size="3" onselect="stopAutoTab();" maxlength="3" style="width:35px;" onkeypress="AutoTabEdit(this,3,event);" onclick="this.value=\'\';"' );
   $class = ( true === $error_type['phoneNumber'] ? 'inputNormalError' : 'inputNormal' );
   $phoneNumber = tep_draw_input_field('phoneNumber', $phone3, 'id="phoneNumber" class="'.$class.'" size="4" onselect="stopAutoTab();" maxlength="4" style="width:40px;" onkeypress="CaptureEnterKey(event);"' );
   $smarty->assign('INPUT_TELEPHONE_NUMBER', $phoneAreaCode . '-' . $phonePrefix . '-' . $phoneNumber);

   if ( 'true' == ACCOUNT_FAX ) {
      $class = ( true === $error_type['faxAreaCode'] ? 'inputNormalError' : 'inputNormal' );
      $faxAreaCode = tep_draw_input_field('faxAreaCode', $fax1, 'id="fax" class="'.$class.'" size="3" onselect="stopAutoTab();" maxlength="3" style="width:35px;" onkeypress="AutoTabEdit(this,3,event);" onclick="this.value=\'\';"' );
      $class = ( true === $error_type['faxPrefix'] ? 'inputNormalError' : 'inputNormal' );
      $faxPrefix = tep_draw_input_field('faxPrefix', $fax2, 'id="faxPrefix" class="'.$class.'" size="3" onselect="stopAutoTab();" maxlength="3" style="width:35px;" onkeypress="AutoTabEdit(this,3,event);" onclick="this.value=\'\';"' );
      $class = ( true === $error_type['faxNumber'] ? 'inputNormalError' : 'inputNormal' );
      $faxNumber = tep_draw_input_field('faxNumber', $fax3, 'id="faxNumber" class="'.$class.'" size="4" onselect="stopAutoTab();" maxlength="4" style="width:40px;" onkeypress="CaptureEnterKey(event);"' );
      $smarty->assign('INPUT_FAX_NUMBER', $faxAreaCode . '-' . $faxPrefix . '-' . $faxNumber);
   }

   } else {
      $class = ( true === $error_type['phoneNumber'] ? 'inputNormalError' : 'inputNormal' );
      $phoneNumber = tep_draw_input_field('phone', $telephone, 'id="phoneNumber" class="'.$class.'"');
      $smarty->assign('INPUT_TELEPHONE_NUMBER', $phoneNumber);
      if ( 'true' == ACCOUNT_FAX ) {
         $class = ( true === $error_type['faxNumber'] ? 'inputNormalError' : 'inputNormal' );
         $faxNumber = tep_draw_input_field('fax', $fax, 'id="fax" class="'.$class.'"');
         $smarty->assign('INPUT_FAX_NUMBER', $faxNumber);
      }
   }


   if ( 'On' == ACCOUNT_AGREE_TO_TERMS ) {
      $smarty->assign('URL_AGREE_TO_TERMS', tep_href_link(ACCOUNT_AGREE_TO_TERMS_URL));
      $terms_values = array(array('id' => '', 'text' => PULL_DOWN_DEFAULT), array('id' => 'yes', 'text' => TEXT_AGREE_TO_TERMS_YES), array('id' => 'no', 'text' => TEXT_AGREE_TO_TERMS_NO));
      $class = ( true === $error_type['agreed_to_terms'] ? 'inputNormalError' : 'inputNormal' );
      $smarty->assign('INPUT_AGREE_TO_TERMS', tep_draw_pull_down_menu('agreed_to_terms', $terms_values, NULL, 'id="agreed_to_terms" class="'.$class.'"'));
   }


   $smarty->assign('INPUT_NEWSLETTER', tep_draw_checkbox_field('newsletter', '1', true, 'id="newsletter"'));


   if ( 'On' == CAPTCHA_REGISTRATION ) {
      $securitycode_error = false;
      if ( true === $show_captcha  )  {
         $security_entered = urlsafe_b64encode(CAP_RC4(CAPTCHA_ENCRYPTION_KEY, (strtoupper(tep_db_prepare_input($_POST['security'])))));
         if ( true === empty($security_entered) || $security_entered != $_SESSION['captcha_secure_code'] ) {
                $securitycode_error = true;
         }
      }
   }

   if ( 'On' == CAPTCHA_REGISTRATION && true === $show_captcha  ) {
         $class = ( true === $error_type['captcha'] ? 'inputNormalError' : 'inputNormal' );
         $smarty->assign('INPUT_CAPTCHA', tep_draw_input_field('security', '', 'class="'.$class.'" size="6" id=""'));
         tep_session_register('captcha_secure_code');
         $generated_captcha_key = tep_create_random_value(CAPTCHA_CHARS_NUM);
         $captcha_secure_code = urlsafe_b64encode(CAP_RC4(CAPTCHA_ENCRYPTION_KEY, (strtoupper(tep_db_prepare_input($generated_captcha_key)))));
         $smarty->assign('CAPTCHA_IMAGE', '<img src="'.DIR_WS_IMAGES.'captcha.php?code='.$captcha_secure_code.'" border="0" style="border:1px #CCCCCC dotted; margin:5px;" id="id_captcha" />');
   }

   $page_content .= tep_draw_form('create_account', tep_href_link(FILENAME_CREATE_ACCOUNT, '', 'SSL'), 'post' );
   $page_content .= '<div>'.tep_draw_hidden_field('action', 'process', 'id="action"' ).'</div>';
   $page_content .= $smarty->fetch('create_account.tpl' );
   $page_content .= '</form>';

   $smarty->assign('page_content', $page_content);

   require_once ( DIR_WS_INCLUDES . 'application_bottom.php' );
   $smarty->display('common/page.tpl' );
?>


i havent been able to get the create account header to show up before the create account

you might also want to change this in templates/xxxx/login.tpl xxxx being what ever template is being used on your site

find
Code: Select all
<p>
{$smarty.const.TEXT_NEW_CUSTOMER|sprintf:$URL_CREATE_ACCOUNT}
</p>


change it to
<p>
{$smarty.const.TEXT_NEW_CUSTOMER}
</p>

now in includes/languages/english/login.php
find
Code: Select all
define('TEXT_NEW_CUSTOMER', 'First time with us ? | <a href="%s">Register here</a>.');


replace with
Code: Select all
define('TEXT_NEW_CUSTOMER', 'First time with us, register below');


Steve
steve_s
 
Posts: 14
Joined: Thu Mar 25, 2010 3:36 pm

Re: combine login/create account in one page

Postby roman vidyayev on Wed Mar 31, 2010 8:57 am

Thanks Steve!

what happens if you only change the template file, say login.tpl and then add registration template to it with a different form action url ?

for example:
Code: Select all
Login:
<form action="login.php?action=login">

login html...

</form>

First time with us, register below...

<form action="create_account.php?action=register">

registration html...

</form>
Everything should be made as simple as possible, but not simpler. -Albert Einstein.
User avatar
roman vidyayev
Site Admin
 
Posts: 247
Joined: Sun Oct 19, 2008 1:10 am
Location: Philadelphia, PA

Re: combine login/create account in one page

Postby steve_s on Wed Mar 31, 2010 12:33 pm

Hi,

I think i tried that, but then the field names where there, but no text boxes, i also tried some other variations, like including the create template, then had like create account, twice, field names, no text boxes and then below that, the correct account template ie field names and text boxes

Steve
steve_s
 
Posts: 14
Joined: Thu Mar 25, 2010 3:36 pm

Re: combine login/create account in one page

Postby roman vidyayev on Wed Mar 31, 2010 9:15 pm

steve_s wrote:Hi,

I think i tried that, but then the field names where there, but no text boxes, i also tried some other variations, like including the create template, then had like create account, twice, field names, no text boxes and then below that, the correct account template ie field names and text boxes

Steve

gotcha! :)

thanks for the contrib man!
Everything should be made as simple as possible, but not simpler. -Albert Einstein.
User avatar
roman vidyayev
Site Admin
 
Posts: 247
Joined: Sun Oct 19, 2008 1:10 am
Location: Philadelphia, PA


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest