I have a simple form, i would like to get all array values one by one and print on PHP. I'll be so happy if you help me.
<php
if(isset($_POST['submit'])){
if(!isset($error)){
try {
if($_POST['mod_[1]']=="1"){
$mod_1 = '1';
$mod_1_symbol = "✓";
}else{
$mod_1 = '0';
$mod_1_symbol = "X";
}
if($_POST['mod_[2]']=="1"){
$mod_2 = '1';
$mod_2_symbol = "✓";
}else{
$mod_2 = '0';
$mod_2_symbol = "X";
}
if($_POST['mod_[3]']=="1"){
$mod_3 = '1';
$mod_3_symbol = "✓";
}else{
$mod_3 = '0';
$mod_3_symbol = "X";
}
if($_POST['mod_[4]']=="1"){
$mod_4 = '1';
$mod_4_symbol = "✓";
}else{
$mod_4 = '0';
$mod_4_symbol = "X";
}
if($_POST['mod_[5]']=="1"){
$mod_5 = '1';
$mod_5_symbol = "✓";
}else{
$mod_5 = '0';
$mod_5_symbol = "X";
}
}catch(PDOException $e) {
$error[] = $e->getMessage();
}
}
}
?>
<form role="form" method="post" action="" enctype="multipart/form-data" class="contact-form">
<input type="checkbox" id="mod_1" name="mod_[]" value="1" />
<input type="checkbox" id="mod_1" name="mod_[]" value="1" />
<input type="checkbox" id="mod_1" name="mod_[]" value="1" />
<input type="checkbox" id="mod_1" name="mod_[]" value="1" />
<input type="checkbox" id="mod_1" name="mod_[]" value="1" />
<input name="submit" type="submit" value="Send">
</form>
i need to get some thing like this: if mod_[1] checked write 1 else 0;
if mod_[2] checked write 1 else 0;
Something like this.
Aucun commentaire:
Enregistrer un commentaire