kipper Posted July 30, 2010 Share Posted July 30, 2010 I am asking if anyone knows of any tutorials to take the contents of a simple form, hit submit, then the values go to an email, the email contents are then parsed and go into the correlating mysql table. For example, if I have a form like this http://nobaltimorebeveragetax.com/ It is only the first name, lastname, email address and zip code. I know how to do a POST or a GET, to put directly into a database table. The reason is because there are multiple sites with this type of form and would like them to go to one central database. I do not wish to do iframe since we would still have to style (css) each form. I have heard of "paring emails". Any tutorial, resources or suggestions would be most appreciated. Thanks Kip Quote Link to comment https://forums.phpfreaks.com/topic/209307-parsing-emails-from-a-web-form-to-database/ Share on other sites More sharing options...
Pikachu2000 Posted July 30, 2010 Share Posted July 30, 2010 Your question isn't very clear. Are you wanting to use forms on multiple domains with one database, or send the user an email and insert record in the database from the same form, or . . . ? Quote Link to comment https://forums.phpfreaks.com/topic/209307-parsing-emails-from-a-web-form-to-database/#findComment-1092964 Share on other sites More sharing options...
ajicles Posted July 30, 2010 Share Posted July 30, 2010 $con = mysql_connect("address","username","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db(""); $sql="INSERT INTO table(ID, first_name, last_name, email_address,zip_code) VALUES ('','" . mysql_real_escape_string($_POST[first_name]) . "','" . mysql_real_escape_string($_POST[last_name]) . "','" . mysql_real_escape_string($_POST[email_address]) . "','" . mysql_real_escape_string($_POST[zip_code]) . "')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } mysql_close($con); And the database dump of the table that should work: -- phpMyAdmin SQL Dump -- version 3.2.0.1 -- http://www.phpmyadmin.net -- -- Host: localhost -- Generation Time: Jul 30, 2010 at 05:11 AM -- Server version: 5.1.36 -- PHP Version: 5.3.0 SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; -- -- Database: `emailing_list` -- -- -------------------------------------------------------- -- -- Table structure for table `data` -- CREATE TABLE IF NOT EXISTS `data` ( `ID` int(11) NOT NULL AUTO_INCREMENT, `first_name` text NOT NULL, `last_name` text NOT NULL, `email_address` text NOT NULL, `zip_code` text NOT NULL, PRIMARY KEY (`ID`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ; -- -- Dumping data for table `data` -- INSERT INTO `data` (`ID`, `first_name`, `last_name`, `email_address`, `zip_code`) VALUES (1, 'John', 'Doe', 'john_doe@domain.com', '12345'); Quote Link to comment https://forums.phpfreaks.com/topic/209307-parsing-emails-from-a-web-form-to-database/#findComment-1092968 Share on other sites More sharing options...
kipper Posted July 30, 2010 Author Share Posted July 30, 2010 No, I know how to to that. Here is the scenario. We have multiple websites that use a slightly different form, but they all collect firstname, lastname, email address and zip code. as in http://nobaltimorebeveragetax.com/. The goal, is to get the data from all these form, into one central database. Rather than each website putting the data in their own database on that server, it needs to go in one central database on a designated server. So, I have heard of email parsing. Rather than have a form, have the submit, and post to that database. The post values go into an email address. Called a paring email. So the values of $fname, $lanme, $email and $zip are sent to an email NOT into a database. Then, a little program receives these emails and parses the information from the content of the email and inserts to that central database. This practice makes it easy, because all you have to so on each form, rather than a POST and a Insert to a database, it sends an email with the vaules. I know this is done alot, because some applications provide a "Parsing email" to it's customers. Make sense? Quote Link to comment https://forums.phpfreaks.com/topic/209307-parsing-emails-from-a-web-form-to-database/#findComment-1093223 Share on other sites More sharing options...
ajicles Posted July 30, 2010 Share Posted July 30, 2010 Some hosts don't allow emails to be sent. Also, in the php just define the database and use it for all the other domains and make a new column and write in which domain it is from. With php mail function you can learn about it @ http://us.php.net/manual/en/function.mail.php It would be easy to keep the info in one database then having to sort tons of emails, it saves on bandwidth or whatever. And knowing where the information comes from having another column for that to just keep track of where it is coming from. Or just use a single database and make a table for each domains. Simple. Trying to download 10 000 emails in Outlook or whatever is a kind of pain lol. And say you wanted to add all the email addresses to a mailing list you can just use php to do that. Quote Link to comment https://forums.phpfreaks.com/topic/209307-parsing-emails-from-a-web-form-to-database/#findComment-1093310 Share on other sites More sharing options...
kipper Posted July 30, 2010 Author Share Posted July 30, 2010 I think you are not understanding what I mean. I know how to send mail, I use mail or phpmailer. I know how to insert into databases. My hosts do allow sending emails. I send one to the person who completes the form. I am asking about an email parsing program. Not who once I have it to insert it into a database. I know to put a variable to (hidden field in the form) to show the origination. The question is not a basic one. I am an intermediate to advanced user. This is an accepted practice where I know there are other method. For our reason, we want to do an email parser. If you don't know, that is fine. Quote Link to comment https://forums.phpfreaks.com/topic/209307-parsing-emails-from-a-web-form-to-database/#findComment-1093381 Share on other sites More sharing options...
ajicles Posted July 30, 2010 Share Posted July 30, 2010 http://lmgtfy.com/?q=email+parser Quote Link to comment https://forums.phpfreaks.com/topic/209307-parsing-emails-from-a-web-form-to-database/#findComment-1093382 Share on other sites More sharing options...
Pikachu2000 Posted July 30, 2010 Share Posted July 30, 2010 Can I just ask why you wouldn't just use one database and have all the forms from the different websites insert the record to it? Seems like it would be substantially less work than sending emails to another script to parse them and insert the records. Quote Link to comment https://forums.phpfreaks.com/topic/209307-parsing-emails-from-a-web-form-to-database/#findComment-1093383 Share on other sites More sharing options...
kipper Posted July 31, 2010 Author Share Posted July 31, 2010 It will go into one database. It is the route. It will cross servers. And, it is the way the application that has the central database is set up. There are many applications set up this way. It's a way to provide to the customer, the ones with the websites, you just provide them with an email address. It is simple for them, the customer. Quote Link to comment https://forums.phpfreaks.com/topic/209307-parsing-emails-from-a-web-form-to-database/#findComment-1093385 Share on other sites More sharing options...
ajicles Posted July 31, 2010 Share Posted July 31, 2010 Quote Can I just ask why you wouldn't just use one database and have all the forms from the different websites insert the record to it? Seems like it would be substantially less work than sending emails to another script to parse them and insert the records. This is why Pikachu: Quote I am asking about an email parsing program. Quote Link to comment https://forums.phpfreaks.com/topic/209307-parsing-emails-from-a-web-form-to-database/#findComment-1093434 Share on other sites More sharing options...
Pikachu2000 Posted July 31, 2010 Share Posted July 31, 2010 Quote Quote Can I just ask why you wouldn't just use one database and have all the forms from the different websites insert the record to it? Seems like it would be substantially less work than sending emails to another script to parse them and insert the records. This is why Pikachu: Quote I am asking about an email parsing program. Yes, I saw that and fully understood it as well. However, without asking a few qualifying questions it wasn't clear whether there would be a better or more efficient way to handle the proposed task. As it stands, I'm still not convinced that this is the best way, however it now at least makes sense as to WHY the OP wants to employ this method. Quote Link to comment https://forums.phpfreaks.com/topic/209307-parsing-emails-from-a-web-form-to-database/#findComment-1093523 Share on other sites More sharing options...
kipper Posted July 31, 2010 Author Share Posted July 31, 2010 How does a web server, with a database, connect to the emails it receives? I appreciate your concern for how I might want to accomplish the task. But, for my reasons ( mostly security and access), the questions still remains the same. Does anyone know how these parsing programs work. I know how to have a form send the submitted values to an email, the email is sent to the designated server with the central database, the part I am stuck on, is when the emails arrives, how does the web server get the contents of the emails so they can parse. I can parse, I can insert into a database, I can mail, etc. It is this part where I was wondering how that is done. So, to keep it simple, How does a web server, with a database, connect to the emails it receives, so the code can insert the parsed email contents into the data base? How does a web server, with a database connect to the emails it receives? How does the web server get the contents of the emails it receives so I can parse it? Quote Link to comment https://forums.phpfreaks.com/topic/209307-parsing-emails-from-a-web-form-to-database/#findComment-1093547 Share on other sites More sharing options...
kipper Posted July 31, 2010 Author Share Posted July 31, 2010 "Set up a POP3 mailbox, use PHP to read the email contents". This solves the issue with connecting to databases across servers. Quote Link to comment https://forums.phpfreaks.com/topic/209307-parsing-emails-from-a-web-form-to-database/#findComment-1093599 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.