Solved

email to a database

Posted on 2004-03-27
4
232 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

929 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

11 Experts available now in Live!

Get 1:1 Help Now