Jump to content

Archived

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

lady_bug

formmailer

Recommended Posts

I'm glad there's a newbie corner cause I don't have a clue how to solve this:

I have a php-mailer script (pre-installed by brinkster.com) and want to use this in my contact file. My php header looks like this:

[code]

(...)

$mail->From = "feedback@mydomain.com";

$mail->FromName = "My Name";

$mail->AddAddress("another@adress.com");

$mail->IsHTML(true);

$mail->Subject = "Feedback";

$mail->Body = $_POST['message'];  
  
if(!$mail->Send())  
{  
echo "Message was not sent <p>";  
echo "Mailer Error: " . $mail->ErrorInfo;  
}  
return TRUE;  


?>

[/code]

and in my html part I have a form that looks like this:

[code]
<form action="<?php print $_SERVER['PHP_SELF']; ?>" method="post">
(...)
<textarea class="input1" name="message" type="text" cols="30" rows="12" tabindex="9"></textarea>
[/code]

So how do I tell my php part which part of the form has to be sent as message body? I guess this $mail->Body = $_POST['message']; is wrong.

thanks for your help!

Share this post


Link to post
Share on other sites
I too wanted to do this but found it didn't work.

MailTo I could get to work. I had for form send the data to the same file as the form, Reload the data into the fields after checking that all the data was correct and then also provide a href mailto link. This works just fine.

I am going to convert that though into the mail() PHP function because supposedly using the many variables of the mailto HTML can cause probs with differenct email clients

I like the way that it gives the user the option to change so when I'm done my form will do the following:

FORM
> Submit to same page.
Reload data into FORM again for checking by user, (this also allows me to check that fields are correctly entered with some PHP if - thens.

Once page reloads the user will have the option of clicking a mailto link or clicking another button in the form that reloads the page again and this time uses the mail() PHP function.

Share this post


Link to post
Share on other sites
Is there all that is to it?
There should be more code, one that sets off the script when the "send" button is clicked...

Share this post


Link to post
Share on other sites
I use a the switch statement / function to differentiate between 2 different buttons from one form.

Use "apply" to send the data through the first run and then "send" or "apply to send it on the second run or change the details.


alternativley you can set a hidden text field with nothing and then on the first run change it to something.

There could be better ways but this way works and I understand it.

Share this post


Link to post
Share on other sites

×

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.