Solved

email to a database

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to refresh a page from a sub domain in ajax ? 34 43
check mysql insert 12 39
Ajax and PHP 4 47
htaccess block all countries but the US 4 35
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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 …

740 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