Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

How a customer can delete his own account?


Guest

Recommended Posts

Posted

Hello i need your help.

 

Could you please tell me how a register customer can delete his own account ?

 

After logging in my shop, a register customer wants delete his own account

 

Is that possible?

Posted

Hello Thank you very much for your answer.

 

But this is not enough .

 

The reason is that our legislation requires that every person who creates an account in a website, has the right to delete hia acount any time he wants . And he must have th possibility to do it by himself.

 

So i need a solution. I need a way that every registered customer be able to delete , remove his account by himself.

 

Does anyone give me a sol;ution?

 

Does anyone can make a contribution about it?

 

or does exist allready a contribution about it?

Posted

George, all code is in admin/customers.php

 

clone the code, and reproduce it as a link on account.php for the customer to use.

:-)

Monika

 

addicted to writing code ... can't get enough of databases either, LOL!

 

my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum

 

Interactive Media Award July 2007 ~ category E-Commerce

my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...

Posted

Monica Thank you Very much

 

I ll try it tomorrow morning Thank you Very much

Posted

Here is a script I put together to have the customer delete their account.

All corrections are welcome - then we can debug it.

So please report your corrections or suggestions.

 

Tested on osCommerce 2.2 Milestone 2 Update 051113

 

Files affected:

catalog/account.php //edit

catalog/includes/filenames.php //edit

catalog/includes/languages/english.php //edit

catalog/check_delete_customers.php //new file

 

----------------------

in catalog/account.php

----------------------

find:

				  <tr>
				<td class="main"><?php echo tep_image(DIR_WS_IMAGES . 'arrow_green.gif') . ' <a href="' . tep_href_link(FILENAME_ACCOUNT_PASSWORD, '', 'SSL') . '">' . MY_ACCOUNT_PASSWORD . '</a>'; ?></td>
			  </tr>

 

change to:

				  <tr>
				<td class="main"><?php echo tep_image(DIR_WS_IMAGES . 'arrow_green.gif') . ' <a href="' . tep_href_link(FILENAME_ACCOUNT_PASSWORD, '', 'SSL') . '">' . MY_ACCOUNT_PASSWORD . '</a>'; ?></td>
			  </tr>
			 <!-- add delete account -->
				<tr>
				<td class="main"><?php echo tep_image(DIR_WS_IMAGES . 'arrow_green.gif') . ' <a href="' . tep_href_link(FILENAME_DELETE_ACCOUNT, '', 'SSL') . '">'. DELETE_ACCOUNT .'</a>'; ?></td>
			  </tr>
			 <!-- end add delete account -->

 

---------------------------------------------------

in catalog/includes/filnames.php add before the ?>

---------------------------------------------------

  define('FILENAME_DELETE_ACCOUNT', 'check_delete_customers.php');

 

-----------------------------------------------------------

in catalog/includes/languages/english.php add before the ?>

------------------------------------------------------------

// added for delete account
define('DELETE_MY_ACCOUNT', 'Delete My Account');
define('PASSWORD_TEXT', 'Password: ');
define('PASSWORD_NOTE', 'Enter Password, then click Continue to delete your account');
define('SUCCESS_ACCOUNT_DELETED', 'SUCCESS ACCOUNT DELETED');
define('DELETE_ACCOUNT', 'Delete Account');

 

-------------------------------------------------------------

copy this code and name it catalog/check_delete_customers.php

-------------------------------------------------------------

<?php
/*
 $Id: check_delete_customers.php, v 1.0 2006/11/27 by pyramids

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 require('includes/application_top.php');

 if (!tep_session_is_registered('customer_id')) {
$navigation->set_snapshot();
tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
 }

 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ACCOUNT_PASSWORD);
$hold_pass =1;
 if (isset($HTTP_POST_VARS['action']) && ($HTTP_POST_VARS['action'] == 'delete_account')) {
$password_current = tep_db_prepare_input($HTTP_POST_VARS['password_current']);

$error = false;

if (strlen($password_current) < ENTRY_PASSWORD_MIN_LENGTH) {
  $error = true;
  $messageStack->add('account_password', ENTRY_PASSWORD_CURRENT_ERROR);
} 

if ($error == false) {

  $check_customer_query = tep_db_query("select customers_password from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'");
  $check_customer = tep_db_fetch_array($check_customer_query);

  if (tep_validate_password($password_current, $check_customer['customers_password'])) {
  $hold_pass = 0;
/////////////////////////////////  
// this is where the customer gets deleted

	tep_db_query("delete from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customers_id . "'");
	tep_db_query("delete from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customers_id . "'");
	tep_db_query("delete from " . TABLE_CUSTOMERS_INFO . " where customers_info_id = '" . (int)$customers_id . "'");
	tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customers_id . "'");
	tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customers_id . "'");
	tep_db_query("delete from " . TABLE_WHOS_ONLINE . " where customer_id = '" . (int)$customers_id . "'");

////////////////////////////////

 $messageStack->add('delete_account', SUCCESS_ACCOUNT_DELETED, 'success');

 tep_session_unregister('customer_id');
 tep_session_unregister('customer_default_address_id');
 tep_session_unregister('customer_first_name');
 tep_session_unregister('customer_country_id');
 tep_session_unregister('customer_zone_id');
 tep_session_unregister('comments');

 $cart->reset();


  } else {
	$error = true;

	$messageStack->add('account_password', ERROR_CURRENT_PASSWORD_NOT_MATCHING);
  }
}
 }
 $breadcrumb->add(DELETE_MY_ACCOUNT, tep_href_link(FILENAME_DELETE_ACCOUNT, '', 'SSL'));
?>
<!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>
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<link rel="stylesheet" type="text/css" href="stylesheet.css">

</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="3" cellpadding="3">
 <tr>
<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
</table></td>
<!-- body_text //-->
<td width="100%" valign="top"><?php echo tep_draw_form('delete_account', tep_href_link('check_delete_customers.php', '', 'SSL'), 'post', 'onSubmit="return check_form(account_password);"') . tep_draw_hidden_field('action', 'delete_account'). tep_draw_hidden_field('customer_id', $customer_id); ?><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 DELETE_ACCOUNT; ?></td>
		<td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_account.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>
<?php
 if ($messageStack->size('account_password') > 0) {
?>
  <tr>
	<td><?php echo $messageStack->output('account_password'); ?></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
<?php
 }
?>
<?php
 if ($messageStack->size('delete_account') > 0) {
?>
  <tr>
	<td><?php echo $messageStack->output('delete_account'); ?></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
<?php
 }
?>

<?php
 if ($hold_pass) {
?>			
  <tr>
	<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
	  <tr>
		<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
		  <tr>
			<td class="main"><b><?php echo DELETE_MY_ACCOUNT; ?></b></td>
			<td class="inputRequirement" align="right"> </td>
		  </tr>
		</table></td>
	  </tr>
	  <tr>
		<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
		  <tr class="infoBoxContents">
			<td><table border="0" cellspacing="2" cellpadding="2">
			  <tr>
				<td class="main"><?php echo PASSWORD_TEXT; ?></td>
				<td class="main"><?php echo tep_draw_password_field('password_current') . ' ' . (tep_not_null(ENTRY_PASSWORD_CURRENT_TEXT) ? '<span class="inputRequirement">'.PASSWORD_NOTE.'</span>': ''); ?></td>
			  </tr>
<?php
} else {

?>	
   <tr>
	<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
	  <tr>
		<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
		  <tr>
		  <!-- blank area to add text if you would like -->
			<td> </td>
			<td align="right"> </td>
		  </tr>
		</table></td>
	  </tr>
	  <tr>
		<td><table border="0" width="100%" cellspacing="1" cellpadding="2">
		  <tr>
			<td><table border="0" cellspacing="2" cellpadding="2"> 
			  <tr>
				<td> </td>
				<td> </td>
			  </tr>	

<?php
}
?>		  
			  <tr>
				<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
			  </tr>


			</table></td>
		  </tr>
		</table></td>
	  </tr>
	</table></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
  <tr>
	<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
	  <tr class="infoBoxContents">
		<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
		  <tr>
			<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
			<td><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT, '', 'SSL') . '">' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>'; ?></td>
			<td align="right"><?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td>
			<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
		  </tr>
		</table></td>
	  </tr>
	</table></td>
  </tr>
</table></form></td>
<!-- body_text_eof //-->
<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- right_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>
<!-- right_navigation_eof //-->
</table></td>
 </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'); ?>

Posted

I updated the script above to hold (and correct) the customer ID , so use this script check_delete_customers.php (not the one above):

 

<?php
/*
 $Id: check_delete_customers.php, v 1.0 2006/11/27 by pyramids

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 require('includes/application_top.php');

if ($HTTP_POST_VARS['customer_id']){
$customer_id = $HTTP_POST_VARS['customer_id'];
}

 if (!tep_session_is_registered('customer_id')) {
$navigation->set_snapshot();
tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
 }

 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ACCOUNT_PASSWORD);
$hold_pass =1;
 if (isset($HTTP_POST_VARS['action']) && ($HTTP_POST_VARS['action'] == 'delete_account')) {
$password_current = tep_db_prepare_input($HTTP_POST_VARS['password_current']);

$error = false;

if (strlen($password_current) < ENTRY_PASSWORD_MIN_LENGTH) {
  $error = true;
  $messageStack->add('account_password', ENTRY_PASSWORD_CURRENT_ERROR);
} 

if ($error == false) {

  $check_customer_query = tep_db_query("select customers_password from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'");
  $check_customer = tep_db_fetch_array($check_customer_query);

  if (tep_validate_password($password_current, $check_customer['customers_password'])) {
  $hold_pass = 0;
/////////////////////////////////  
// this is where the customer gets deleted

	tep_db_query("delete from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customer_id . "'");
	tep_db_query("delete from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'");
	tep_db_query("delete from " . TABLE_CUSTOMERS_INFO . " where customers_info_id = '" . (int)$customer_id . "'");
	tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "'");
	tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "'");
	tep_db_query("delete from " . TABLE_WHOS_ONLINE . " where customer_id = '" . (int)$customer_id . "'");

////////////////////////////////

 $messageStack->add('delete_account', SUCCESS_ACCOUNT_DELETED, 'success');

 tep_session_unregister('customer_id');
 tep_session_unregister('customer_default_address_id');
 tep_session_unregister('customer_first_name');
 tep_session_unregister('customer_country_id');
 tep_session_unregister('customer_zone_id');
 tep_session_unregister('comments');

 $cart->reset();


  } else {
	$error = true;

	$messageStack->add('account_password', ERROR_CURRENT_PASSWORD_NOT_MATCHING);
  }
}
 }
 $breadcrumb->add(DELETE_MY_ACCOUNT, tep_href_link(FILENAME_DELETE_ACCOUNT, '', 'SSL'));
?>
<!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>
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<link rel="stylesheet" type="text/css" href="stylesheet.css">

</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="3" cellpadding="3">
 <tr>
<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
</table></td>
<!-- body_text //-->
<td width="100%" valign="top"><?php echo tep_draw_form('delete_account', tep_href_link('check_delete_customers.php', '', 'SSL'), 'post', 'onSubmit="return check_form(account_password);"') . tep_draw_hidden_field('action', 'delete_account'). tep_draw_hidden_field('customer_id', $customer_id); ?><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 DELETE_ACCOUNT; ?></td>
		<td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_account.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>
<?php
 if ($messageStack->size('account_password') > 0) {
?>
  <tr>
	<td><?php echo $messageStack->output('account_password'); ?></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
<?php
 }
?>
<?php
 if ($messageStack->size('delete_account') > 0) {
?>
  <tr>
	<td><?php echo $messageStack->output('delete_account'); ?></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
<?php
 }
?>

<?php
 if ($hold_pass) {
?>			
  <tr>
	<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
	  <tr>
		<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
		  <tr>
			<td class="main"><b><?php echo DELETE_MY_ACCOUNT; ?></b></td>
			<td class="inputRequirement" align="right"> </td>
		  </tr>
		</table></td>
	  </tr>
	  <tr>
		<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
		  <tr class="infoBoxContents">
			<td><table border="0" cellspacing="2" cellpadding="2">
			  <tr>
				<td class="main"><?php echo PASSWORD_TEXT; ?></td>
				<td class="main"><?php echo tep_draw_password_field('password_current') . ' ' . (tep_not_null(ENTRY_PASSWORD_CURRENT_TEXT) ? '<span class="inputRequirement">'.PASSWORD_NOTE.'</span>': ''); ?></td>
			  </tr>
<?php
} else {

?>	
   <tr>
	<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
	  <tr>
		<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
		  <tr>
		  <!-- blank area to add text if you would like -->
			<td> </td>
			<td align="right"> </td>
		  </tr>
		</table></td>
	  </tr>
	  <tr>
		<td><table border="0" width="100%" cellspacing="1" cellpadding="2">
		  <tr>
			<td><table border="0" cellspacing="2" cellpadding="2"> 
			  <tr>
				<td> </td>
				<td> </td>
			  </tr>	

<?php
}
?>		  
			  <tr>
				<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
			  </tr>


			</table></td>
		  </tr>
		</table></td>
	  </tr>
	</table></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
  <tr>
	<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
	  <tr class="infoBoxContents">
		<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
		  <tr>
			<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
			<td><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT, '', 'SSL') . '">' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>'; ?></td>
			<td align="right"><?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td>
			<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
		  </tr>
		</table></td>
	  </tr>
	</table></td>
  </tr>
</table></form></td>
<!-- body_text_eof //-->
<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- right_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>
<!-- right_navigation_eof //-->
</table></td>
 </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'); ?>

Archived

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

×
×
  • Create New...