Solved

email to a database

Posted on 2004-03-27
4
231 Views
Last Modified: 2011-09-20
How do I collect survey data using email and then automagically put the data collected inti a database using PHP/MySql ?
0
Comment
Question by:kaller2
4 Comments
 
LVL 3

Assisted Solution

by:JtR
JtR earned 100 total points
ID: 10694551
best you let all post form fields start with an identically id eg: <input name="db2store_name"...> <input name="db2store_email" ... > and so on

if send these values will be put into array $_POST[]  where you can search the values

$first_el = true;
      
$sql_query = "INSERT INTO table_name ( ";
$keys = array_keys($_POST);

foreach ($keys as $key)
{
      if (eregi( "db2store_", $key))
     {
            if ($first_el)
        { $sql_query .= eregi_replace( "db2store_","",$key);
                  $first_el = false; }
             else
          $sql_query .= ", ".eregi_replace( "db2store_","",$key);
     }
}
$sql_query .= ") VALUES (";
reset( $keys );
            
$first_el = true;
foreach ($keys as $key)
{
     if (eregi( "db2store_", $key))
     {
      if ($first_el)
            { $sql_query .= "'".$_POST[$key]."'"; $first_el = false; }
      else
            { $sql_query .= ", '$_POST[$key]'"; }
    }                              
}
$sql_query .= ");";

db->query( $sql_query ); // here comes your mysql_query() command!!!
0
 
LVL 13

Assisted Solution

by:kenfcamp
kenfcamp earned 50 total points
ID: 10694976
Is the data being received through a survey form on your site?

Or are you looking to archive data received through email

Your question is a little vague
0
 

Accepted Solution

by:
adamcharnock earned 100 total points
ID: 10695422
If users are replying to an email then the best option could be to create a POP3 mailbox for that email address where all the replies are stored. You could then write a PHP script that opens the mailbox using PHPs built in features. The script could read in the data, manipulate it as required, and then add it into the database.

Hope this helps a little!

Radam
0
 
LVL 2

Author Comment

by:kaller2
ID: 10696813
Yes, I want to send an email survey to selected users and they answer the questions on the email and reply by return mail.
Then the email should be processed into a database.
So I get a php script to open the mails - sure OK.
Should I use html or xml format for the mail body do you think?
 

0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now