Forum Moderators: coopster
A) Display an html version of the completed form that the user can print out.
B) Email that same html version to administrator so she can print it out for her own records.
Now that means I've had to start learning and experimenting with php from scratch. I've gotten as far as figuring out how to get the form to pass the information I need. I know how to make the script produce an html page with the finished form for viewing. But I'm stuck when it comes to emailing the completed html page to the administrator.
I've tried using mail() but it can only handle plain text or string messages. I need to be able to send the html by email to the admistrator which I can't do, even if I configure mail() to send html emails. The problem is that I can't just plunk my script into mail(). So I'm at a loss of what to do. I need some help.
Can anyone point me in the right direction of how to accomplish this? Is there an alternate way to send email through php that will allow me to use my code? Or is there a way for me to create the html file as an attachment and send that instead?
I've got two versions of the code. One is a mix of html and php. The other is just using php to spit out everything. They're not terribly long, only 70 lines each, but I wasn't sure if it was too long to post so I'll wait to see if anyone needs it.
Are you not saving the submited form data in mysql?
Just create a view.php with all the content end send the link including the id to your admistrator.
The link would look like this:
[yoursite.com...]
Then selects from mysql data with $id = $id
like this:
mysql_query("SELECT data FROM mytable WHERE (id = $id)")
An option you may want to look into is PHP's Output Control Functions [php.net]. You can push all your output into a "buffer" and at the very end, instead of the end of script pushing the data to the browser you can grab the contents and do something with the contents, including email them.