if(isset($ _ POST [" submit"])不工作

时间:2017-05-17 13:32:12

标签: php

isset功能在此页面上无效,但在其他页面上工作。 我想编辑我的数据库,这就是为什么我创建了这个,但我无法获取文本字段的值只是因为isset不起作用。

这是代码

<?php 

$link = mysqli_connect("localhost","root","","officedb");

if(!$link)
{
    echo"Not connected";
}



$query = "SELECT * from items";

$result = mysqli_query($link,$query);

    if(!$result)
    {
        echo"Not selected";
    }



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

        echo "Hello";

    }





?>

<html>


    <head>

     <link rel="stylesheet" href="bootstrap-3.3.7-dist/css/bootstrap.min.css" >


        <style>

        .lb
            {
                background-color:#ADD8E6;
                text-align: center;
            }

            .tl
            {
                text-align: center;
            }

            .disapp
            {
                display:none;
            }


        </style>


        <script>

            function divshow(){

              if(document.getElementById("entryname").value == "Name")
                  {
                      document.getElementById("nameed").style.display = 'block';
                       document.getElementById("nsned").style.display = 'none';
                       document.getElementById("quned").style.display = 'none';

                  }

                if(document.getElementById("entryname").value == "NSN/Part")
                  {
                      document.getElementById("nameed").style.display = 'none';
                      document.getElementById("nsned").style.display = 'block';
                       document.getElementById("quned").style.display = 'none';
                  }

                if(document.getElementById("entryname").value == "Quantity")
                  {
                      document.getElementById("nameed").style.display = 'none';
                      document.getElementById("nsned").style.display = 'none';
                       document.getElementById("quned").style.display = 'block';
                  }
            };


        </script>





    </head>


<body>

    <div class="container">
    <table class="table table-hover">
    <tr>
    <th class="lb" >Serial #</th>
        <th class="lb" >Name</th>
        <th class="lb" >NSN/part</th>
        <th class="lb" >Quantity</th>


 <?php       
while($row = mysqli_fetch_array($result))
{
?> 

        <tr>

            <td class="tl"><?php echo $row["S.NO"]; ?></td>
            <td class="tl"><?php echo $row["Name"]; ?></td>
            <td class="tl"><?php echo $row["NSN/Part"]; ?></td>
            <td class="tl"><?php echo $row["Quantity"]; ?></td>

        </tr>

        <?php } ?>

    </table>




             <div class="border" style="border:1px solid grey;border-radius:6px;width:50%;margin-left:25%">

            <div class="row" style="margin-top:7%;">




                <div class="col-lg-4 col-lg-offset-3" style="margin-left:33%;">


            <form method="POST">

  <label>Select Item Serial #:</label>

  <select class="form-control">



      <?php

       $sql = "SELECT * from items";

      $newar=mysqli_query($link,$sql);



      while($edit = mysqli_fetch_array($newar)){  ?>

      <option value = <?php $edit[0]; ?> > <?php  echo $edit[0]; }  ?> </option>



  </select>

                  <label style="margin-top:7%;">Select entry</label>
  <select class="form-control" name="entryname" onchange="divshow()">
    <option value="Name">Name</option>
    <option value="NSN/Part">NSN/Part</option>
      <option value="Quantity">Quantity</option>
  </select>





                 <div id="nameed" >
        <input type="text" placeholder="Enter New Name" class="form-control"  required name="namtxt"  style="margin-top:16%;" />
        </div>

        <div id="nsned" class="disapp" >
        <input type="text" placeholder="Enter New NSN/Part" class="form-control"  required name="nsntxt"  style="margin-top:16%;" />
        </div>

        <div id="quned" class="disapp" >
        <input type="text" placeholder="Enter New Quantity" class="form-control"  required name="quntxt"  style="margin-top:16%;" />
        </div>



                <div class="text-center">

                <input type="submit" name="submit" style="width:70%;margin-top:20%;" class="btn btn-success btn-md" value="Edit" /> 

                </div>



                    </form>


                </div>

                    </div> 

                </div>




    </div>
</body>






</html>

1 个答案:

答案 0 :(得分:1)

问题在这里这是必填字段,但它没有显示在前端,当你提交表单时,from没有提交它会在代码中产生java脚本错误所以首先解决这个问题

    app.factory('httpResponseErrorInterceptor', ['$q', '$injector', function($q, $injector, $http) {
    return {
        'responseError': function(response) {
            if (response.status === 401) {
                // should retry
                let deferred = $q.defer();
                let $http = $injector.get('$http');
                $.ajax({
                    url        : PUBLIC_API_URI,
                    type       : 'HEAD',
                    beforeSend : function(request) {
                        request.setRequestHeader('Authorization', api_access_key);
                    },
                    success    : function(result, status, xhr) {
                        console.log("error -> ok : should retry");
                        deferred.resolve(xhr.getResponseHeader('Authorization'));
                    },
                    error      : function(xhr, status, error) {
                        console.log("error -> bad : should give up");
                        deferred.resolve(null);
                    }
                });
                console.log(deferred.promise);
                if(deferred.promise == null)
                    return $q.reject(response);
                response.config['Authorization'] = api_access_key = deferred.promise;
                return $http(response.config);
            }

            return $q.reject(response);
        }
    };
}]);