Extracting data from email to database

They have: 4 posts

Joined: Sep 2004

I have a tracking script which emails me whenever I have a new customer. The emails contain form field data (eg Field1: data Field2: data etc.) which I would like to be entered into a database.
What's the simplest way to achieve this?

I have very little experience with databases and don't currently have one set up but my server has MySql so it would be logical to use that but my options are open. I'd appreciate any suggestions and links to relevant information or products.

Thanks

They have: 30 posts

Joined: Aug 2003

1. create a new DB user and new database for your site. (in control panel?)
2. create a new table in the database with the fields Field1, Field2, etc as needed. (in phpMyAdmin)
2. write a small PHP script that will insert the necessary data in the database.

example:

<?php
mysql_connect
("localhost", "<username>", "<password>");
mysql_select_db("<database>");

// write form data to PHP variables
$field1 = $_POST[Field1];
$field2 = $_POST[Field2];

mysql_query("INSERT INTO <database> (Field1, Field2) VALUES ('$field1', '$field2')");

echo
"Thank you! Form submitted successfully"
?>

You need to replace , , with appropriate info. The $_POST[...] bit refers to the form data. If your form method is set to GET, then use $_GET[...] instead. You can modify the SQL query as needed to add more fields to the database.

Busy's picture

He has: 6,151 posts

Joined: May 2001

insert the details into the database then send you an email on success, easier than the other way round

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.