Wells-it.com - Web Hosting

Extracting data from email to database

You are viewing this site as a guest. Join our community to get your questions answered and share knowledge. Active members may advertise and ask for a website critique.

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.

You really should know more about our $1.95 web hosting deal.

Busy's picture
Modrater

He has: 6,157 posts

Joined: May 2001

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

<?bhb if(broken){ echo("It wasn't me Smiling "); } ?>
Learn HTML the ez way - EzHTML.net

Some people are like slinkies, they dont really serve any purpose but they still bring a smile to your face when you push them down the stairs ...