PHP Classes

Parse importer: Import email addresses into a MySQL database

Recommend this page to a friend!
  Info   View files Example   Screenshots Screenshots   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 237 This week: 1All time: 8,048 This week: 89Up
Version License PHP version Categories
importerfp2db 0.5Freely Distributable5.0Email, PHP 5, Databases
Description 

Author

This class can import email addresses into a MySQL database.

It takes a string or an uploaded file with email addresses and parses the file to extract the addresses and insert them into a MySQL database table.

The email addresses are sanitized and validated to prevent inserting invalid email addresses.

The database and the table where the email addresses will be inserted, are configurable parameters.

Picture of Oliver Leuyim Angel
  Performance   Level  
Name: Oliver Leuyim Angel <contact>
Classes: 7 packages by
Country: Mexico Mexico
Age: 37
All time rank: 114512 in Mexico Mexico
Week rank: 91 Up2 in Mexico Mexico Up

Recommendations

What is the best PHP class to extract recipients from CSV file?
I need to parse a .csv emails address list and send a message

Example

<form action="" method="POST" enctype="multipart/form-data">

emails:<textarea cols='35' rows='15' name='address'></textarea>
<br>gile:<input type='file' name='addresses'>
<br>Group:<input type='text' name='grupo'>

<br>
<input type="submit" value="Send!" name="submit">
</form>

<?php

if(!empty($_POST['address']) or !empty($_FILES['addresses']))
{

require(
"class.import.php");
$import = new Import();

$import->grupo = $_POST["grupo"];
$import->dbtableName = "datatable";
$import->identify();
$resultaqdo = $import->procesar();
if(
$resultaqdo){
   
    print
"
    <fieldset style=\"border-color:green;background-color:#C0FFC0;color:black;text-decoration:blink;\">
    <legend>Alert!</legend>
    Pefect Uploaded... "
.count($resultaqdo)." contacto(s).
    </fieldset>
    "
;
}else{
    print
"
    <fieldset style=\"border-color:red;background-color:#FF9D9D;color:black;text-decoration:blink;\">
    <legend>Alerta!</legend>
    Got stock.
{$import->show_errors()}
    </fieldset>
    "
;
}

}
?>


Details

This class was developed for a project then is released to use it at freeway. Feel free to use it and upgrade it. Any comment to: oliver.angel@dimworks.org Author: Oliver Leuyim Angel www.dimworks.org

IMPORTER CLASS

PUBLIC PROPERTIES

public $grupo; ///This establish the group is going to be inserted the emails that are going to be extracted public $error_end; /// This is for save the error_log not for to show it

PRIVATE PROPERTIES

private $file; //To store the global $_FILES private $data; private $correos; //For the mixed string before the export private $lista_correos; //for the exported mail addres private $error = array(); // Error log array

Public methods

public identify() // to identify the globals public connectDatabase() // for conecct to the db public procesar() // to ejecute and parse public show_errors() // to show the errors

* Private methods

private extract_email_address($string) // the extract function

steps on the process

1) get all globals and connect to db. 2) mix all content of the globals $_FILES and $_POST in a string 3) extract all mails address of the string 4) store all mail address on a data base.

In case of error show errors.


Screenshots  
  • importer.jpg
  Files folder image Files  
File Role Description
Plain text file class.import.php Class The class file, where have all functions
Accessible without login Plain text file db.sql Data the table of the class
Accessible without login Plain text file example.php Example Example for use this class
Accessible without login Plain text file Readme Doc. Information of the class

 Version Control Unique User Downloads Download Rankings  
 0%
Total:237
This week:1
All time:8,048
This week:89Up
User Comments (1)
Parse importer.
10 years ago (shyam6511)
77%StarStarStarStar