How to get the unchecked value

Discussion in 'PHP' started by mrame, Apr 16, 2009.

  1. #1
    Hi,

    I'm new to PHP. I use one.php which calls two.php.
    one.php:
    if($qry[0]!=$login_type)
    {
    echo "<td class=tabhead align=center style=background-color:#CC66CC>
    <input type=checkbox name=check value=disabled CHECKED DISABLED /></br>".$slot_value."</td>";
    }
    else
    {
    echo "<td class=tabhead align=center style=background-color:#00CCCC><input type=hidden name=hidden[] value='--user ".$slot_value." --ne ".$nen." --timespec ".$slt."'><input type=checkbox name=enable[] value='--user ".$slot_value." --ne ".$nen." --timespec ".$slt."' CHECKED></br>$slot_value</td>";
    }


    two.php:
    if(isset($_POST["enable"]) == false || $_POST["enable"] == ""){
    $value = $_POST["hidden"];
    echo $value;
    }


    I have shown a snippet. Many <td> is generated. Something like below is generated.
    <td class=tabhead align=center style=background-color:#00CCCC><input type=hidden name=hidden[] value='--user amiranda --ne ES10 --timespec 17-18'><input type=checkbox name=enable[] value='--user amiranda --ne ES10 --timespec 17-18' CHECKED></br>amiranda</td>
    ....
    <td class=tabhead align=center style=background-color:#00CCCC><input type=hidden name=hidden[] value='--user amiranda --ne ES10 --timespec 18-19'><input type=checkbox name=enable[] value='--user amiranda --ne ES10 --timespec 17-18' CHECKED></br>amiranda</td>

    So. if these two are unchecked, I need those values. I have some problem in two.php.

    Any help is apreciated.
     
    mrame, Apr 16, 2009 IP
  2. jimbursch

    jimbursch Peon

    Messages:
    33
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Unchecked values won't get passed as a $_POST variable, so I think this might be your solution:

    if (isset($_POST['check1'])) {$check1=$_POST['check1'];} else {$check1=0;}
    if (isset($_POST['check2'])) {$check2=$_POST['check2'];} else {$check2=0;}



    if(isset($_POST["enable"]) == false || $_POST["enable"] == "")

    I think that should be:

    if((isset($_POST["enable"]) && $_POST["enable"] == false) || $_POST["enable"] == "")
     
    jimbursch, Apr 16, 2009 IP