English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I was wondering if there is a way to make a table in MySQL database transfer user data to another table once I recieve an email. In theory, the php script would be able to check the inbox, and match the data in the table, with their email address, then it moves that line of data to another table. Is this possible?

2006-09-18 07:19:01 · 2 answers · asked by detroitkid17 2 in Computers & Internet Programming & Design

2 answers

In theory you could, but it would be extremely difficult and probably unreliable. You do realize that they could have just made an order through a form on your website rather than doing this effect right? Then all you would have to do is send them a confirmation order via email with a URL link in it. They click the link to be taken to a page where then it matches their email address with the table and moves the record over.

Having PHP check the email is not at all standard practice and has a bunch of parts to it; too complicated to go into detail about on here. I would go with the more acceptable practice on this one if I were you and have them fill out a form, you send a confirmation email with a link, they click the link to confirm the order and you can then move the record.

Hope this helps! Good luck!

2006-09-18 09:18:25 · answer #1 · answered by Martyr2 7 · 2 0

Yes, this is possible, but it requires root-level access privileges on the server. There are at least two ways of doing it.

1. Some mail servers (procmail in particular, if I remember correctly) are capable of running programs following the recipt of a message into a specific mailbox. So you could configure your mail sever to run your PHP script every time a message lands in a specific mailbox.

2. If this is not an option, you could schedule periodic runs of a script that would retrieve mail from a specific mailbox, parse it, and do the necessary actions.

This said, the idea of moving data between tables is probably bad. There is absolutely no need to have two tables when one would do. Consider adding a status code field to one table and dropping the other altogether. If you do that, you would be able to simply update a status code (one UPDATE query) rather than do three queries (SELECT from the source table, INSERT into destination table, and DELETE from the source table). Also, the proper way of doing the two-table thing is using transactions, which you can avoid with a single table.

2006-09-20 05:16:01 · answer #2 · answered by NC 7 · 0 0

fedest.com, questions and answers