2016-04-12 6 views
0

Veritabanlarım projesinde, kullanıcının istediği bilgileri seçebileceği bu formu yapıyorum ve bir html sayfasında görüntülenecektir. Şu an için sadece bir sorunla karşılaştığım onay kutularını uyguluyorum.PHP - Kontrol edilen onay kutusu değerine erişilemiyor

Sorun şu ki, onay kutularını işaretlediğimde (şimdiki uygulamam için yalnızca işlem sayfamdaki "Konum" + "Boru Tipi" + "Tutar") kullanıcının "fe_page2" adresini kontrol ettiği durumla ilgileniyorum. php ", onay kutularının işaretli olup olmadığını denetleyen koşullara hiçbir zaman ulaşılamaması yerine, her zaman başka bir koşula gider. Kod aşağıda verilmiştir.

Bu benim temel html sayfası: Bu

<?php 

require('dbconf.inc'); 

db_connect(); 

print"<pre>"; 
print_r($_POST); 
print"</pre>"; 

$pipelocation = $_POST[pipelocation]; 
$pipetype = $_POST[Pipe-Type]; 
$pipeamount = $_POST[amount]; 

if($pipelocation=='value1' && $pipetype == 'value2' && $pipeamount == 'value3'){ 

    $qrySel="SELECT `Pipe_ID`, `Location`, `Amount`, `PipeType` FROM pipe order by Pipe_ID desc"; 
    $resSel = mysql_query($qrySel); 

    if($resSel){ 

     while($rowpipe = mysql_fetch_array($resSel, MYSQL_ASSOC)){ 
      echo "Pipe ID:{$rowpipe['Pipe_ID']} <br> ". 
      "Location: {$rowpipe['Location']} <br> ". 
      "Amount: {$rowpipe['Amount']} <br>". 
      "PipeType: {$rowpipe['PipeType']} <br>". 
      "--------------------------------<br>"; 
     } 

     echo "Fetched Data Successfully!\n";  

    } 
} 
else{ 
    echo"never went in!"; 
} 

db_close(); 



?> 

Ben

if(isset($pipelocation) && isset($pipetype) && isset($pipeamount)){ 
    ..... 
} 

ve kaldırma gibi farklı şeyler denedim fe_page2.php php sayfası

<html> 
<head> 
    <title>Flow Element</title> 
</head> 
<body> 
    <h1 style="margin-left: 450px">Retrieve Flow Element Information</h1> 
    <hr> 
    <form action="fe_page2.php" method="post"> 
    All Times: 
    <input type="checkbox" name="alltimes" onchange="changeFields()"><br><br> 
    Start Date: 
    <input type="date" name="startdate" id="startdate"> 
    Start Time: 
    <input type="time" name="starttime" id="starttime"><br><br> 
    Same Time: 
    <input type="checkbox" name="sametime" id = "sametime" onchange="sameFields()"><br><br> 
    End Date: 
    <input type="date" name="enddate" id="enddate"> 
    End Time: 
    <input type="time" name="endtime" id="endtime"><br><br> 

    <h3> Select fields of output</h3> 
    <hr> 

    Pipe Key: <input type="text" name="pipepirmary" id="pipekey"><br> 

    <input type="checkbox" name="pipelocation" id="pipeLocation" value="value1" > 
    Location<br> 

    <input type="checkbox" name="Pipe-Type" id="pipetype" value="value2"> 
    Pipe-Type<br> 

    <input type="checkbox" name="amount" id="amount" value="value3"> 
    Amount<br><br> 

    Flow Element:<input type="text" name="fepirmarykey" id="fekey"/><br> 

    <input type="checkbox" name="flow" id="flo"> 
    Flow<br> 

    <input type="checkbox" name="temperature" id="temp"> 
    Temperature<br> 

    <input type="checkbox" name="pressure" id="pres"> 
    Pressure<br><br> 

    <input type="submit"> 
</form> 
    <script> 
     function changeFields() { 

      if(document.getElementById("startdate").disabled == false){ 
       document.getElementById("startdate").disabled = true; 
       document.getElementById("starttime").disabled = true; 
       document.getElementById("enddate").disabled = true; 
       document.getElementById("endtime").disabled = true; 
       document.getElementById("sametime").disabled = true; 
       if(document.getElementById("sametime").checked = true){ 
        document.getElementById("sametime").checked = false; 
        } 
       document.getElementById("startdate").value = null; 
       document.getElementById("starttime").value = null; 
       document.getElementById("enddate").value = null; 
       document.getElementById("endtime").value = null; 
      } 
      else{ 
       document.getElementById("startdate").disabled = false; 
       document.getElementById("starttime").disabled = false; 
       document.getElementById("enddate").disabled = false; 
       document.getElementById("endtime").disabled = false; 
       document.getElementById("sametime").disabled = false; 
      } 

     } 
     function sameFields() { 
      if(document.getElementById("enddate").disabled == false){ 
       document.getElementById("enddate").disabled = true; 
       document.getElementById("endtime").disabled = true; 
       document.getElementById("enddate").value = null; 
       document.getElementById("endtime").value = null; 
      } 
      else{ 
       document.getElementById("enddate").disabled = false; 
       document.getElementById("endtime").disabled = false; 
      } 
     } 
    </script> 

</body> 
</html> 

html sayfasından değer ve aşağıdaki kod parçasını kullanarak:

if($pipelocation == 'on' && $pipetype == 'on' && $pipeamount == 'on'){ 
       ... 
    } 

Ama yine de hayır şans ... Herhangi bir yardım mutluluk duyacaktır.

sunulmuştur kod tamamen benim işim ama aşağıda sağlanan referans gelen kod parçalarını içerdiğini unutmayın: https://www.youtube.com/watch?v=LZtXYa9eGGw

cevap

1

Burada alıntılar cevapsız:

$pipelocation = $_POST['pipelocation']; 
$pipetype = $_POST['Pipe-Type']; 
$pipeamount = $_POST['amount']; 
+1

Oh tanım , Teşekkür ederim. Şu an çok aptalım. Tekrar teşekkürler! –

+0

Bazen böyle olur. Endişelenecek bir şey yok. –