Forum Moderators: coopster

Message Too Old, No Replies

form - send all fields

         

leoo24

5:01 pm on Aug 2, 2004 (gmt 0)

10+ Year Member



Hey guys :)

I came across a post someone had made by where they had a php form submit all fields, something very simple like with the "mailto" which sends all the fields, no need for declaring variables etc, but i'll be damned if i can find it, anyone know what i'm on about?

Cheers

Leo

RonPK

5:44 pm on Aug 2, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Maybe not the script you're looking for, but why not simply loop through all the posted variables?

foreach($_POST as $key => $val) { 
$message .= "$key: $val\n";
}
mail($to, $subject, $message);

leoo24

6:00 pm on Aug 13, 2004 (gmt 0)

10+ Year Member



hi thanks for the reply (sorry for the daly in responding), i found it:

<?php
$email = $HTTP_POST_VARS[email];
if (!$email) $email = "user@domain.com";
$mailto = "your email address";
$mailsubj = "user contact";
$mailhead = "From: $email\n";
$mailbody = $HTTP_POST_VARS[message];
if ($name) {
$mailbody .= "\n\n";
$mailbody .= "From: $name\n";
}
mail($mailto, $mailsubj, $mailbody, $mailhead);
?>

could someone confirm this would work and all i need do is point the form action to this script? thanks :)

Timotheos

6:11 pm on Aug 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sorry leoo24 that script is not going to work unless you only have one field named "message". Use RonPK's example.