Okay I guess I'll jump right into this. I'm new at PHP. I was asked at work to setup an online form. Once the user fills out this form it should do 2 things.

A) Display an html version of the completed form that the user can print out.
😎 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.

    Well I tried running the script and all I get is an error. I'm not sure what in the script I need to change to get it to work properly. The error is:

    Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/lodan/public_html/htmlMimeMail5/htmlMimeMail5.php on line 30

    Since then I managed to find a way to get it to work the way I want tho. Just letting you know that I can't get this script to work properly.

      Hey yotamono,

      Basically, what you should do is this:

      • process your regular HTML form in a separate php page (submit action will be for instance email.php, which handles the processing)

      • in the php page, you retrieve the values entered. You write the static text you want to surround the data (like "Your name is: $name"), and then you let the dynamic data (posted by the user) show up where it should be

      • you now e-mail this to a predefined e-mail, and you show this on the email.php page. The e-mail command is:

      mail(recipient, topic, message, optional headers)

      I hope this gives you more ideas. Go to php.net, google, or this actual phpbuilder website to find out more. And just let it know if and where you get stuck (paste the php code).

        Write a Reply...