# Submit Button To Send To Email



## Jaymie1989 (Apr 28, 2007)

I am creating a form and when users click the submit button i want it to send to my email address.

I am using php and this is the code i am using.

```

```
Any reason why it doesnt work?


----------



## Gibbs (Feb 28, 2005)

Use the mail function.


----------



## Jaymie1989 (Apr 28, 2007)

Thanks,

I am confused to where i put it.

Here is the page so far

```
Other Donating Options

    To Email The Administrator About The Other Donating Methods Please Fillin The Form Below.

      Name:

         Username :

        Email Address:

 

How Much Would You Like To Donate?

US Dollars:

UK Pounds:
```


----------



## MMJ (Oct 15, 2006)

Read http://php.net/manual/en/function.mail.php carefully.

If you still don't know what to do read the comments.


----------



## martin2006 (Jan 12, 2006)

Jaymie1989 said:


> Thanks,
> 
> I am confused to where i put it.
> 
> ...


Hey,

to get this to work you need to use the mail() function to send the form contents to you in an email.

An exmaple of this in your code would be:


```
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Other Donating Options

<?php
$action=$_REQUEST['action'];
if ($action=='sendemail') {
  // get form contents
  $name=$_REQUEST['name'];
  $username=$_REQUEST['username'];
  $email=$_REQUEST['email'];
  $donation=$_REQUEST['donation'];
  $currency=$_REQUEST['currency'];
	  //Sending Email to user
	$pfw_header = "From: $email\n"
	. "Reply-To: $email\n";
	$pfw_subject = "Donation Details!\n";
	$pfw_email_to = "[email protected]\n";
	$pfw_message = "\n\n"
	. "Name: $name\n"
	. "Username: $username\n"
	. "Email Address: $email\n"
	. "Donation: $donation\n"
	. "Currency: $currency\n"
	."------------------------------------------------------------------------------";
	$send=mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;
	if ($send==1) {
	$output="Your Message has been successfully sent!";
	} else {
	$output="There has been a problem sending the message!";
	}

} else {
?>

	To Email The Administrator About The Other Donating Methods Please Fillin The Form Below.

	Name:

	Username :

	Email Address:

 

How Much Would You Like To Donate?

Donation :

	  United States Dollars (USD)

	  Great British Pounds (GBP)

 

<?php
}
?>
```
Hope that helps you if not let me know and i'll try explain it further.

Regards,
Martin
[email protected]


----------

