0

I have made a PHP checkbox form, which should send me an email with the chosen options and the text from the textarea field. The problem is that I am a novice in PHP checkbox forms (this is my first attempt to try something like this), and it gives me some errors when hitting submit button. I have xampp installed and the servers are active, the *.php is in the htdocs, so it isn't because of these things. Hope you can help me. <?php $to = "[my real email]"; $subject = "Shop request:"; ; $language = $_REQUEST['i'] ; $message = $_REQUEST['message'] ; $details = "Subject: $subject\n Item: $i \n Message: $message \n "; ini_set("sendmail_from", $email); $ok = mail($to, $subject, $message); if ($ok) { echo "<p>Mail sent!</p>"; } else { echo "<p>Mail could not be sent. Sorry!</p>"; } ?>

<form action="http://localhost/contactus.php" method="post" enctype="multipart/form-data">
                  <br>
                  <table width="58%" border="0" align="center" cellpadding="0" cellspacing="0">
                      <tr>
                        <td height="1" align="left" valign="middle">Items:</td>
                        <td align="left">
                        
                          <input type="checkbox" name="i[]"    value="B1">B1
<input type="checkbox" name="i[]"  value="B2">B2
<input type="checkbox" name="i[]"  value="B3">B3                        </td>
                      </tr>
                      <tr>
                        <td height="40" align="left" valign="middle">Adress:</td>
                        <td align="left"><label for="message"></label>
                        <textarea name="message" id="message" cols="45" rows="5"></textarea></td>
                      </tr>
                      <tr>
                        <td height="40" align="left">&nbsp;</td>
                      <td align="left"><input type="submit" value="Send" />                      </tr>
                    </table>
                  </form>
John Smith
  • 13
  • 1
  • 7
  • Forgot to add the errors: Notice: Undefined index: i in C:\xampp\htdocs\contactus.php on line 4 Notice: Undefined variable: i in C:\xampp\htdocs\contactus.php on line 8 Notice: Undefined variable: email in C:\xampp\htdocs\contactus.php on line 11 Warning: mail(): SMTP server response: 553 Invalid RFC821 mailbox specification. in C:\xampp\htdocs\contactus.php on line 13 Mail could not be sent. Sorry! – John Smith Apr 20 '16 at 16:09
  • you need a `foreach` for the checkboxes or implode and this `$i` that's undefined. – Funk Forty Niner Apr 20 '16 at 16:09

0 Answers0