Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Autofill email field for client in Login Box


mutter

Recommended Posts

Hi, today is was searching for a contrib to autofill the email field in the login box but i didnt find nothing. I didnt wanted to install some of the autologin contribs cause it seems they create some conflicts with other contribs and spiders.

 

I am newbie with php, so please backup the files you will change. Please let me know if it works for you.

 

in catalog/includes/application_top.php

after:

	if ($spider_flag == false) {
  tep_session_start();
  $session_started = true;
}
 } else {
tep_session_start();
$session_started = true;
 }

 

add:

// set cookie for a month only with the customer email
if (tep_session_is_registered('customer_id') ) {
if ($recordar_email == 1) {
 $ccliente_query = tep_db_query("select customers_email_address from " . TABLE_CUSTOMERS . "  where customers_id = '" . $customer_id . "'");
 $correo_cliente = tep_db_fetch_array($ccliente_query);
tep_setcookie('cookie_correo_osc', $correo_cliente['customers_email_address'], time()+60*60*24*30, $cookie_path, $cookie_domain);
} elseif($recordar_email != 1) {
tep_setcookie('cookie_correo_osc', '', time()-3600, $cookie_path, $cookie_domain);
}
}
// end customer autofill email code

 

in catalog/login.php

after:

  if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'process')) {
$email_address = tep_db_prepare_input($HTTP_POST_VARS['email_address']);
$password = tep_db_prepare_input($HTTP_POST_VARS['password']);

 

add:

// email autofill - get the values from the checkbox to work with the variable
 if($HTTP_POST_VARS['recordar_email'] != 1) tep_session_unregister('recordar_email');	
 if($HTTP_POST_VARS['recordar_email'] == 1) tep_session_register('recordar_email');
//end email autofill

 

then after:

				  <tr>
				<td class="main"><b><?php echo ENTRY_PASSWORD; ?></b></td>
				<td class="main"><?php echo tep_draw_password_field('password'); ?></td>
			  </tr>
			  <tr>

 

add:

				  <tr>
				<td class="main"><b><?php //echo 'Put text here fi you want'; ?></b></td>
				<td class="main"><?php echo tep_draw_checkbox_field('recordar_email', '1'); ?> Remember my e-mail</td>
			  </tr>

 

 

that's all, later...

Link to comment
Share on other sites

Hi Ruben,

 

Unfortunately it did not work for me which is a shame because I really like the idea.

 

Mark

 

Sorry, i missed the step where the email field in the login box gets the cookie value (customer email) lol!!. And the query to the customer email isn't necessary, so ditch my first post and follow this steps. Another thing to note is that i am not using ssl, so i dont know if this work with stores usign ssl.

 

 

REMEMBER TO BACKUP...

In includes/application_top.php

 

Just after

  } else {
tep_session_start();
$session_started = true;
 }

 

Add:

  // cookie para llenar mail automatico
if (tep_session_is_registered('customer_id') ) {
if ($recordar_email == 1) {
tep_setcookie('cookie_correo_osc', $correo_cliente, time()+60*60*24*30, $cookie_path, $cookie_domain);
} elseif($recordar_email != 1) {
tep_setcookie('cookie_correo_osc', '', time()-3600, $cookie_path, $cookie_domain);
}
}
// fin recordar correo del cliente

 

in login.php

 

After:

  if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'process')) {
$email_address = tep_db_prepare_input($HTTP_POST_VARS['email_address']);
$password = tep_db_prepare_input($HTTP_POST_VARS['password']);

 

Add:

// Checar los valores del checkbox para guardar email del cliente	
 if($HTTP_POST_VARS['recordar_email'] == 1) tep_session_register('recordar_email');
// fin

 

then search for:

		$customer_country_id = $check_country['entry_country_id'];
	$customer_zone_id = $check_country['entry_zone_id'];

 

Add:

		$correo_cliente = $check_customer['customers_email_address']; // para poner email en la sesion aqui abajito

 

Search for:

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

 

Add:

		tep_session_register('correo_cliente'); // se usa para poner cookie de recordar email

 

now search for this:

				  <tr>
				<td class="main"><b><?php echo ENTRY_EMAIL_ADDRESS; ?></b></td>
				<td class="main"><?php echo tep_draw_input_field('email_address'); ?></td>
			  </tr>
			  <tr>
				<td class="main"><b><?php echo ENTRY_PASSWORD; ?></b></td>
				<td class="main"><?php echo tep_draw_password_field('password'); ?></td>
			  </tr>

 

and reaplace it with:

 

				  <tr>
				<td class="main"><b>
				<?php 
				if (isset($_COOKIE['cookie_correo_osc'])) $autollenar = $_COOKIE['cookie_correo_osc']; 								
				echo ENTRY_EMAIL_ADDRESS; ?></b></td>
				<td class="main"><?php echo tep_draw_input_field('email_address', $autollenar); ?></td>
			  </tr>
			  <tr>
				<td class="main"><b><?php echo ENTRY_PASSWORD; ?></b></td>
				<td class="main"><?php echo tep_draw_password_field('password'); ?></td>
			  </tr>
			  <tr>
			  <tr>
				<td class="main"><b><?php //echo 'Checkbox Text'; ?></b></td>
				<td class="main"><?php echo tep_draw_checkbox_field('recordar_email', '1', CHECKED); ?> Remember my e-mail</td>
			  </tr>

 

That's all, now this step is not necessary but to avoid having the customer email variable in the session in

catalog/logoff.php

 

above of just after:

  tep_session_unregister('customer_id');

 

Add:

  tep_session_unregister('recordar_email'); // cookie customer email field mod
 tep_session_unregister('correo_cliente'); // cookie customer email field mod

 

Let me know if works now.. later.

Link to comment
Share on other sites

Hi Ruben,

 

Made the changes as instructed above but still no joy m8 unfortunately.

 

Regards

 

Mark

 

oh maybe the problem are your cookie paths in your includes/configure.php file

 

i have mine like this

 define('HTTP_COOKIE_DOMAIN', '127.0.0.1');
 define('HTTPS_COOKIE_DOMAIN', '');
 define('HTTP_COOKIE_PATH', '/catalog/');
 define('HTTPS_COOKIE_PATH', '');

 

can you show me your please..

 

This mod should save a cookie in the customer browser when he logon and select the remember me checkbox. So first check that you get a cookie called cookie_correo_osc with the email addres value when you login.

Link to comment
Share on other sites

oh maybe the problem are your cookie paths in your includes/configure.php file

 

i have mine like this

 define('HTTP_COOKIE_DOMAIN', '127.0.0.1');
 define('HTTPS_COOKIE_DOMAIN', '');
 define('HTTP_COOKIE_PATH', '/catalog/');
 define('HTTPS_COOKIE_PATH', '');

 

can you show me your please..

 

This mod should save a cookie in the customer browser when he logon and select the remember me checkbox. So first check that you get a cookie called cookie_correo_osc with the email addres value when you login.

 

Has anyone with SSL tried this please? :)

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...