Answer the question
In order to leave comments, you need to log in
How to make an application form with optional fields?
for example, there is a feedback form on the landing page, there are 5 fields, 2 fields are required, but how to make the remaining 3 optional, only 2 fields are filled, then send them to the mail, if 3 then only 3, and so on.
here is the handler:
<?php
if (!empty($_POST['name']) AND !empty($_POST['phone']) AND !empty($_POST['email']) AND !empty($_POST['quantity']) AND !empty($_POST['address'])) {
$theme = "New message from the site";
$letter = "This message:";
$letter .="\n\n";
$letter .="\nName: ".$_POST['name'];
$letter .="\nPhone: ".$_POST['phone'];
$letter .="\nE-mail: ".$_POST['email'];
$letter .="\nQuantity: ".$_POST['quantity'];
$letter .="\nAddress: ".$_POST['address'];
if (mail("[email protected]", $theme, $letter)){
header("Location: thanks.html");
} else {
header("Location: error.html");
}
} else {
header("Location: error.html");
}
Answer the question
In order to leave comments, you need to log in
I don't understand php. But there seems to be threads for this.
https://ru.stackoverflow.com/questions/605555/Vali...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question