Add Custom Field and email message

I have a form in php in “single.php” from my site (wordpress). In it, the person adds your email address and a specific message is sent to it.
I would like to modify this form for a custom field is sent along the message she receives.
What I need to modify my code?

`

<? php
if (isset ($ _POST ['action']) && $ _POST ['action'] == 'email-att ") {
*** if (is_email ($ _POST ['email'])) {
******** $ to = $ _POST ['email'];
******** $ subject = "email subject line";
******** $ message = "email message body";
******** $ attachments = array ('http://full_url_to_file.zip');
******** wp_mail ($ to, $ subject, $ message,'', $ attachments);
******** echo 'Email sent! Check your email ';
**** else {}
******** echo 'Please enter a valid email address';
**** }
}
?>

`

`

<form name="email-att" id="email-att" method="POST" action="">
Enter your emial: <br />
<input type="text" name="email" id="email"/> <br />
<input type="hidden" name="action" value="email-att"/> <br />
<input type="submit" name="submit" value="Submit" id="submit"/>
</ form>

`

these two codes are together in single.php


<? php
if (isset ($ _POST ['action']) && $ _POST ['action'] == 'email_att') {

  if (is_email ($_POST ['email'])) {
    $to = $ _POST ['email'];
    $subject = "email subject line";
    $message = "email message body";
    $attachments = 'http://full_url_to_file.zip';
    wp_mail ($to, $subject, $message,'', $attachments);
    echo 'Email sent! Check your email ';
 }else{
   echo 'Please enter a valid email address';
 }
}
?>

<form name="email_att" id="email_att" method="POST" action="">
Enter your email: <br />
<input type="text" name="email" id="email"/> <br />
<input type="hidden" name="action" value="email_att"/> <br />
<input type="submit" name="submit" value="Submit" id="submit"/>
</form>

Give that a try (untested).

PHP vars (and hence the form elements submitted to it) cannot contain hyphens - variables

The code you posted had spaces between the $ and the variable name, not allowed.

$attachments was an array (with one item) yet you tried to submit the array, read the man page on mail for more information.

I would test this without the attachments first, then add them when you are sure the rest of it is working as it should be.