Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

True mail php script - check this out! 1

Status
Not open for further replies.

LinuXelite

Programmer
Jun 21, 2002
150
CA
HI!

I need a mail script.

I have this HTML code:

<form action='mail.php?sendto=foo@bar.com'>
Enter name: <input type='text' name='name'>
What do you want:<input type='text' name='wduw'>
</form>

Ok... Its easy to program a php script like that:
<?php
return mail ($sendto, '', $name . '\n' . $wduw, null );
?>

But I want to programs a mail script that will work like that...

<?php
for each textbox, checkbox, listbox, option as object
$message .= '\n' . object.name . '=' . object.value
return mail ($sendto, $message, null );
?>

A mail script that can be used with ANY form, without having to code EVERY form object.

Is there a script out there that can do that? Or may be its just impossible with PHP?

Frank,




 
Code:
<?php
$message = &quot;Hello. This email was sent from a form.\n&quot;;
foreach ($_POST as $name => $value)
        $message .= &quot;$name = '$value'\n&quot;;
mail(&quot;your@email.com&quot;, &quot;Form mail&quot;, $message);
?>
should do it.

//Daniel
 
I always recommend to use phpmailer.sourceforge.net as it is an excellent class that has all functionality you'd ever like from a mail application.
You don't have to worry about the right headers, MIME types etc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top