I am new to PHP coding and am trying to write code to format form output in an e-mail message. I have created a large form accessed on http://www.pinesofsarasota.org/employment_opportunites.htm. You need to click on the very small character at the bottom right of the page to go into the form itself. What I would like to do is have the user's input sent in an e-mail to a human resource (HR) person in a format much like the form itself. If that isn't possible, I would like the output to be as user-friendly as possible.

I think sending the form submittal to HR by e-mail is the way to go. However, maybe setting up the form results to create a file might be a suitable alternative. I don't know how to do the latter and would appreciate any help at all.

Thank you

    Well you can basically copy and paste your HTML code for your form and place it into a var on the post page (you would need to get rid of the form elements and use the post vars though)

    
    //####################################################################################
    		//####################################################################################
    //now we build our email
    $to 		= //the to  EmailAddress goes here
    $subject 	= //what appears in the subject line of the email goes here
    $header  	= "From: <From email address goes here>\nMIME-Version: 1.0\r\n";
    $header    .= "Content-type: text/html; charset=iso-8859-1\r\n";//leave alone
    
    $message    = "This is where your HTML code would go to display your form results";
    
    
    
    //**************************************** email ***********************************************************
    
    $from = " '-fFromEmail' ";//leave the -f put the from email address after it without spaces
    
    
    
    mail($to, $subject, $message, $header,$from)//put any error trapping code here if you like
    
    
    	//****************************************end of email *******************************************************
    
    

    Hope this helps

      BTW clicked on your link and got

      Not Found
      The requested URL /employment_opportunites.htm was not found on this server.

        well now it is working....got to love it. 🙂

          Please excuse my ignorance as I am a newbie. When you refer to "var" are you referring to "$message" in the mail function?? If so can I put all the html code into $message as is?

          Also I don't understand the "$from" variable. I thought the mail function only used four parameters? Could you please explain the "$from" variable more fully?

          Thanks mucho

            Yes when I was referring to var I was talking about $message. You can put all of your html and php code inside it to make the email look anyway you need. Of course you would need to access your form entries that the user posted by accessing the post variables like $HTTP_POST_VARS["firstname"] or the short hand if your web server is setup for it.

            the mail function has optional parameters for additional headers

            You can read more here http://us2.php.net/function.mail

              Write a Reply...