Jump to content

PHP Form Handler


cjbeck71081

Recommended Posts

I have a client that needs an Email form that sends the information to a PHP handler that will process the information put in the form, Format it based on settings i provide, and Email it off to the chosen user.

I know how to create the form, and set it up in PHP to email the information to the Email address of the chosen user.

The thing im not familiar with is how to format the information and template it to an HTML file, so when the user recieves the email it is easy to read.  If anyone has any information on this i would appreciate it.

Thank You
Chris
Link to comment
https://forums.phpfreaks.com/topic/33740-php-form-handler/
Share on other sites


cj,

There are two things you need to do to make this work:

[list]
[*]Create the html data
[*]Pass special header information & html page to the mail function you are using
[/list]

The html data can be contained in a variable.  Example:

[code]
<?php

$to = "email address";
$subject = "subject";

$html_out = <<<END

<p>the results of your form submission:</p>
<ul>
  <li>Form Variable 1: $formvar1</li>
  <li>Form Variable 2: $formvar2</li>
  <li>Form Variable 3: $formvar3</li>
  <li>Form Variable 4: $formvar4</li>
</u>

END;

?>
[/code]

Then set your header information

[code]
<?php
$header = "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html; charset=iso-8859-1\r\n";
?>
[/code]

and send your message:

[code]
<?php
mail($to, $subject, $html_out, $header);
?>
[/code]

Hope this helps.

- B
Link to comment
https://forums.phpfreaks.com/topic/33740-php-form-handler/#findComment-158227
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.