0

I have currently got some php which sends a form to an email when it is completed. The issue is, I want the form to submit when two options must be selected not all of the options.

The form is a basic input form with 5 options, 2 of them being required.

<?php
///I thought this would work since I'm only requesting two inputs V
if (isset($_POST['optionOne']) && isset($_POST['option'])){

    $optionOne=$_POST['optionOne'];
    $tick=$_POST['tick'];
    $results=$_POST['results'];
    $option=$_POST['option'];
    $requirements=$_POST['requirements'];

    $to= "bonniethompson12345@gmail.com";
    $subject="submit";
    $body="This course is identified in my Work Plan and Learning Agreement: $optionOne \n \n I am attending this session because: $tick \n \n What would you like to achieve as a result of your attendance: $results \n \n Do you require adjustments or additions to the session delivery to support your participation: $option \n \n Please provide details of your requirments: $requirements";

    $send = mail($to, $subject, $body);
    if ($send) {
        echo 'message sent!';
    }else {
        echo "error";
    }
}
?> 
Bonnie Thompson
  • 77
  • 1
  • 10
  • The email is only went when a user fills all the inputs of the form, which I don't want. I want to email to send when the user has fills the inputs I have put as "required". so the email should send with the requried inputs of optionOne and option, but the other inputs can be empty. Right now everything has to be filled (non required options) – Bonnie Thompson May 14 '19 at 03:14
  • Your form is vulnerable to [XSS attacks](https://stackoverflow.com/questions/1996122/how-to-prevent-xss-with-html-php) – Machavity May 14 '19 at 03:18
  • How does the other post answer this question? – Bonnie Thompson May 14 '19 at 03:26
  • I need some of the options to be required and some optional. – Bonnie Thompson May 14 '19 at 03:46

0 Answers0