?
Solved

email to a database

Posted on 2004-03-27
4
Medium Priority
?
240 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 3

Assisted Solution

by:JtR
JtR earned 300 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 14

Assisted Solution

by:kenfcamp
kenfcamp earned 150 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 300 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to count occurrences of each item in an array.
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…
Suggested Courses

770 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