2016-05-23 28 views
1

Isset($ _ POST ['submit')は動作しませんが、not操作(!私はどこにエラーを見つけることはありません。ここ は、ここに私のコード

$get = isset($_GET['id']) ? $_GET['id'] : ""; 
$query = "SELECT * FROM `crew_info` WHERE `id` = '$get'"; 
$query_run = mysqli_query($conn,$query); 

    if(!isset($_POST['submit'])) { 

     $query_update = "UPDATE `crew_info` SET `crew_status` = 'NEW' WHERE `id` = '$get'"; 
     if ($query_update_run = mysqli_query($conn,$query_update)) { 

      echo 'Crew Accepted'; 
     } 

    } 

で提出フォームあなたが任意の値を提出していない

<form action="review.php" method="POST"> 

    <table border="2" align="center" width="600" cellspacing="3" cellpadding="4"> 
     <tr> 
      <th>First Name</th> 
      <th>Middle Name</th> 
      <th>Last Name</th> 
      <th>Date Added</th> 
      <th>Status</th> 
     </tr> 
     <tr>'; 
     while($record = mysqli_fetch_assoc($query_run)) { 
     echo "<tr>"; 
     echo "<th>".$record['first_name']."</th>"; 
     echo "<th>".$record['middle_name']."</th>"; 
     echo "<th>".$record['last_name']."</th>"; 
     echo "<th>".$record['date_added']."</th>"; 
     echo "<th>".$record['crew_status']."</th>"; 
     echo '</tr>'; 
     } 
    echo '</table>'; 
    echo '<br><center><input type="submit" name="submit"></center> 
</form> 
+0

私のコードで試してみてください。何か案が? –

+0

提出書類はありますか?どこから投稿セット? –

+0

はい。私は自分の投稿を編集しました –

答えて

0

です。

<input type="submit" name="submit"> 

このような何かを試してみてください:

​​

PHPチェックのこの作品名 "提出" とフォーム要素は、任意の値がある場合:

"if isset($_POST['submit'])" 

をしかし、あなたの避難所以降」 "submit"の値を設定すると、検証されません。あなたはそれの前に感嘆符を設定するときしかし、それが検証されます:あなたは「『提出』は値が設定されていない場合は、次の手順を実行します」、と言っているので、これは

!if isset($_POST['submit'])" 

を。

希望は意味があります。 :)

更新:あなたはまた、すべてのものを動作させるために修正する必要があるいくつかの他のエラーがあります。これはほとんどの問題を解決するはずです。現在のコードと比較する:

<?php $get = isset($_GET['id']) ? $_GET['id'] : ""; 
$query = "SELECT * FROM crew_info WHERE id = '$get'"; 
$query_run = mysqli_query($conn,$query); 

if(isset($_POST['submit'])) { 

    $query_update = "UPDATE crew_info SET crew_status = 'NEW' WHERE id = '$get'"; 
    if ($query_update_run = mysqli_query($conn,$query_update)) { 

     echo 'Crew Accepted'; 
    } 

} ?> 

<form action="review.php" method="POST"> 

<table border="2" align="center" width="600" cellspacing="3" cellpadding="4"> 
    <tr> 
     <th>First Name</th> 
     <th>Middle Name</th> 
     <th>Last Name</th> 
     <th>Date Added</th> 
     <th>Status</th> 
    </tr> 
    <tr> 

<?php 
    while($record = mysqli_fetch_assoc($query_run)) { 
    echo "<tr>"; 
    echo "<th>".$record['first_name']."</th>"; 
    echo "<th>".$record['middle_name']."</th>"; 
    echo "<th>".$record['last_name']."</th>"; 
    echo "<th>".$record['date_added']."</th>"; 
    echo "<th>".$record['crew_status']."</th>"; 
    echo '</tr>'; 
    } 
echo '</table>'; 
echo '<br><center><input type="submit" name="submit" value="ok"></center>'; 
?> 

</form> 
+0

の接続が機能していません。私は試しました

+0

どのように動作していませんか? – Guyra

+0

何も起こらなかった –

関連する問題