I need to paste data received as e-mail text files into an html form that sends the data to a mysql database via a php file that filters the data into the relevant cells in the mysql table.
The data arrives and is copied into an input box like this:
First name: John
Last name: Smith
telephone: 01234 56789
What php would remove “First name:” from the string and post “john” into the first name column of the database likewise with “Last name” and “telephone”
building the html form and database is not a problem; my php though is not quite yet up to speed!
Thanks in advance.
As I understand you receive plain text emails with data.
Then you want to parse it. If your ‘labels’ are automatically generated and consistent then you can parse it quite easily… say something like this:
Say you load your email text into a variable $email_content.
In the end you will have an array like this:
Then you will be able to easily access whichever value you like by key and subsequently save it to database if you like.
There are certain assumptions though – that you only have : in lines that contain label:value pairs. Also end of the line char is always /n. But this is just a pointer not a ready made solution.