I have this working code, but now I have to make sure the user can only check a maximum of two checkboxes.
if (isset($_POST['submit'])) {
if (isset($_POST['steady_state']) ||
(isset($_POST['ssrates']) ||
(isset($_POST['unsteady_state']) ||
(isset($_POST['usgas']) ||
(isset($_POST['centrifuge_single']) ||
(isset($_POST['centrifuge_multi']) ||
(isset($_POST['porous'])))))))) {
header("Location: /portal.php");
$_SESSION['steady_state_portal'] = $_POST['steady_state'];
$_SESSION['ssrates_portal'] = $_POST['ssrates'];
$_SESSION['unsteady_state_portal'] = $_POST['unsteady_state'];
$_SESSION['usgas_portal'] = $_POST['usgas'];
$_SESSION['centrifuge_single_portal'] = $_POST['centrifuge_single'];
$_SESSION['centrifuge_multi_portal'] = $_POST['centrifuge_multi'];
$_SESSION['porous_portal'] = $_POST['porous'];
So, when for example the first and third checkbox is checked, the first and third $_SESSION is set.
Now, for the maximum of checkboxes I tried to change all names of the checkboxes to: name="checkbox" and then set the $_SESSION to:
$_SESSION['steady_state_portal'] = $_POST['checkbox'] && value==='steady_state';
But when I check one checkbox, all the $_SESSION are set instead of the one applied to the value. I didn't work on the count yet, because first I have to set the $_SESSION right. Can this be done with the existing code or do I need JavaScript? In both cases I need some help in the right direction.
Aucun commentaire:
Enregistrer un commentaire