Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Getting Emails from database to use on Newsletters


Guest

Recommended Posts

Posted

Hello, i'm using the code above to get the Members Email and names from users who subscribe newsletters, but can be very usefull if i can get also from database the country from where my users came, what code changes for i can get everithing in only one file???? Anyone can help????

 

 

<?php

######## TAB-DELIMITED TEXT FILE EXPORTER FOR EXTERNAL MAIL LIST IMPORT

# Should work for most all osC versions, used on MS2.2 and earlier

# By Richard Bartz, [email protected]

# HOW TO INSTALL

# This little script is just to export all of the email addresses from your osC

# customer database who have subscribed to your newsletter to a tab delimited file

# that can be imported into a better mailer such as phpList.

#

# 1. Change the $filename variable to whatever file name you want.

# 2. upload this file in the osC admin directory

# 3. in admin/includes/boxes/tools.php add: tep_admin_files_boxes('email_export.php', 'Email Export') .

# or on OLD veraions add

# '<a href="' . tep_href_link('email_export.php', '', 'NONSSL') . '" class="menuBoxContentLink" target="_blank">Email Export</a><br>'.

# 4. That's it! Click on "Email Export" in Admin->Tools! Save and import.

# 5. Security: If you use .htaccess in admin you are safe.

# If you use admin add-ons then requiring the application_top.php should do it.

# In either case the file should NOT run from a direct call.

########

 

$filename="addresses.txt"; //.txt is good for import into excel workbook as tab delimited file

 

// end of configuration!

require('includes/application_top.php'); // gives us SOME security anyway

require_once('includes/configure.php'); // gives us osC database info

 

header('Content-Type: text/x-csv');

header('Content-Disposition: attachment; filename="' . $filename . '"');

header('Expires: 0');

header('Cache-Control: must-revalidate, post-check=0, pre-check=0');

header('Pragma: public');

 

if ( mysql_connect ( DB_SERVER , DB_SERVER_USERNAME , DB_SERVER_PASSWORD )) {

$sql = "SELECT customers_firstname, customers_lastname, customers_email_address " ;

$sql .= "FROM customers WHERE customers_newsletter = '1'" ;

$result = mysql_db_query ( DB_DATABASE , $sql );

echo "email\tFirst Name\tLast Name\n";

while ( $row = mysql_fetch_array($result)) {

if ($row[customers_email_address]) {

echo "$row[customers_email_address]\t$row[customers_firstname]\t$row[customers_lastname]\n";

}

 

}

}

mysql_close ();

?>

 

 

 

Best Regards

Archived

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

×
×
  • Create New...