--- jipsy1234 <[EMAIL PROTECTED]> wrote:

> I need a very simple script that will take the contents of an online
> form and email the form fields to a designated email address.
>
> Hopefully it will be portable and not require any changes when the form
> fields change.

Have you already determined that your PHP server can successfully send email?

If you want a PHP equivalent to the Perl script formmail.pl then Google for formmail.php and you
will see many links.  The Perl/PHP formmail implements required fields and a number of other
features which may be desirable.

I'm not a big fan of sending emails with a bunch of variable=value pairs.  You have to do
something with the data.  Isn't it usually better to put it in a database where you can access the
info with greater flexibility?

However, that said, you could do something simple like this:

$to    = "[EMAIL PROTECTED]";
$subj  = "Some form data just came in";
$from  = "From: [EMAIL PROTECTED]";
$body  = print_r($_POST, true);
mail($to, $subj, $body, $from);

It is possible (even likely) that the print_r() function uses newlines.  Since email is supposed
to have \r\n pairs at the end of each line, you might have to use a regular _expression_ to fix this
(unless there is a PHP function I don't know which can fix the line endings).

James
_____


James D. Keeline
http://www.Keeline.com  http://www.Keeline.com/articles
http://Stratemeyer.org  http://www.Keeline.com/TSCollection

http://www.ITeachPHP.com -- Free Computer Classes: Linux, PHP, etc.
Spring Semester January-June 2006.  Two new class topics.


Community email addresses:
  Post message: [email protected]
  Subscribe:    [EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-list




YAHOO! GROUPS LINKS




Reply via email to