0

The skills are an option tag in the form, but the unselected options are showing an undefined index after submission in the process page. This is the code i used in the process page:

if (isset($_POST['submit_form'])) {
    $name    = strip_tags($_POST['name']);
    $email   = strip_tags($_POST['email']);
    $subject = htmlspecialchars($_POST['subject']);
    $gender  = strip_tags($_POST['gender']);
    $country = strip_tags($_POST['country']);
    $comment = trim(htmlspecialchars($_POST['comment']));
    $skills1 = $_POST['skills1'];
    $skills2 = $_POST['skills2'];
    $skills3 = $_POST['skills3'];
    $skills4 = $_POST['skills4'];
    $skills5 = $_POST['skills5'];

    $ins_sql = "INSERT INTO comments (name, email, subject, gender, skills1, skills2, skills3, skills4, skills5,  country, comment) VALUES ('$name', '$email', '$subject', '$gender', '$skills1', '$skills2', '$skills3', '$skills4', '$skills5', '$country', '$comment')";
    $run_sql = mysqli_query($conn, $ins_sql);
} else {

}
  • Ouch! Never rely on user data (and don't think, if you provide a form, you will get requests from that form only). Don't build dynamic queries when not really necessary. **Never ever** interpolate or concat unescaped data into any SQL string. Read about `mysqli_real_escape_string` and even better *prepared statements*. – Pinke Helga Dec 17 '16 at 13:28
  • I think you should post the html too. Do you have any checkboxes and/or radio buttons in your form ? If these are not selected/checked they will not be available in your $_POST superglobal – Andreas Dec 17 '16 at 13:32

0 Answers0