Forum Moderators: coopster

Message Too Old, No Replies

PHP Form completly lost!

I need help

         

jimboharris21

10:39 am on Sep 1, 2008 (gmt 0)

10+ Year Member



I have done a simple form, it sends info by email and it works,

the form has input fields butto label them on the email i have to use hidden inputs

example

<?

// send form results through email

$recipient = "##@##.com";
$subject = "Booking Enquiry";
$forminfo =
(
$_POST['h1'] . "\r" .
$_POST['surname'] . "\r" .
$_POST['h2'] . "\r" .
$_POST['contact'] . "\r" .
$_POST['h4'] . "\r" .
$_POST['date'] . "\r" .
$_POST['h5'] . "\r" .
$_POST['time'] . "\r" .
$_POST['h6'] . "\r" .
$_POST['adults'] . "\r" .
$_POST['h7'] . "\r" .
$_POST['kids'] . "\r" .
$_POST['h8'] . "\r" .
$_POST['comments'] . "\r" .
$_POST['email'] . "\r" .

date("d-M-Y") . "\r\n\n");

$formsend = mail("start", "$recipient", "$subject", "$forminfo");
?>

But i dont want to use the hidden feilds, i would like it to show the name of the input feild then the value, and if no value then not display it in the email

Can anyone help?

Thanks in advance

eelixduppy

5:45 pm on Sep 1, 2008 (gmt 0)



Hello and Welcome to WebmasterWorld! :)

Maybe something like this to construct your email message body:


$message = '';
foreach($_POST as $name => $value)
$message .= $name . ': ' . $value . "\n";

Try something like that and see what you get.

jimboharris21

7:51 am on Sep 5, 2008 (gmt 0)

10+ Year Member



Thanks, you are a legend! works a treat, just my math problem to sort out now

jimboharris21

7:58 am on Sep 5, 2008 (gmt 0)

10+ Year Member



however, I print the output on the next page, it displays submit:submit Any ideas?

jatar_k

1:53 pm on Sep 5, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



what do you mean by the next page? a different one than the one you are coding above?

what exactly are you echo'ing?

eelixduppy

4:24 pm on Sep 5, 2008 (gmt 0)



From the looks of it, you are naming your submit button on your form "submit" and it is echoing that with the script, as well. You can omit that from the print results but checking for it.

jimboharris21

8:07 am on Sep 7, 2008 (gmt 0)

10+ Year Member



on one page is the form on the second is this script and the result of the form printed for the user, how do i omit this?