0

Trying to combine to drop down fields into the body the email that is sent here is my code. Only returns 1 drop down. Want to combine message and message 1 from drop downs to the $comment field Tried multiple solutions online but cannot seem to find one that works. Please help

  $admin_email = "CrazyCatLadyBrewing@baunochs.com";
  $email = $_REQUEST['email'];
  $subject = "Beverage Request";
  $comment = $_REQUEST['message']);


  //send email
  mail($admin_email, "$subject", $comment, "From:" . $email);

  //Email response
  echo "Thank you for contacting us!";
  }

  //if "email" variable is not filled out, display the form
  else  {
?>

<form method= "post" action= "<?php echo $_SERVER [ 'PHP_SELF' ] ;?>" />
  <table>
    <tr>
        <td>Email: <input name="email" type="text" /><br />
        </td>
    </tr>
    <tr>
      <td>Beverage Choice </td>
        <td><select id="message1" Name="message1">
                <option value="Beer">Beer</option>
                <option value="Wine">Wine</option>
                <option value="Cidar">Cidar</option>
            </select>
        </td>

        <td>Size of bottle </td>
        <td><select id="message" Name="message">
                <option value="Sample">Sample</option>
                <option value="12 oz">12 oz</option>
                <option value="22 oz">22 oz</option>
                <option value="32 oz">32 oz</option>
            </select>
        </td>


    </tr>
    <tr>
  • looks to me as this post would answer your question [html-php-form-input-as-array](https://stackoverflow.com/questions/20184670/html-php-form-input-as-array) – chilly Aug 17 '17 at 10:25
  • you could read $_POST['message1'] as you do the 'message' counterpart. BTW: you should check $_POST['email'] really contains a mail address (and not more than that) Else some one can take over your mail form and send messages of his own, using your server for his spam – Ivo P Aug 17 '17 at 10:29
  • you realize there's a syntax error here – Funk Forty Niner Aug 17 '17 at 10:41

1 Answers1

0
$admin_email = "CrazyCatLadyBrewing@baunochs.com";

$email = $_REQUEST['email'];

$subject = "Beverage Request";

$comment = $_REQUEST['message']." ".$_REQUEST['message1']; 

You need to concatenate message and message1 value to store in $comment variable.

  • Perfect That is exactly what I was looking for. Thanks so much and for the quick response. Im not a php coder so I was lost. :) – Stuart Baunoch Aug 17 '17 at 10:39