Solved

email to a database

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

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PHP installation issues 11 59
paypal ipn to mysql 3 35
website maintenance mode 1 16
How to submit record from external php form to a Sharepoint list? 5 29
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
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…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

813 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

12 Experts available now in Live!

Get 1:1 Help Now