表格动作和方法[关闭]

问题描述 投票:0回答:0

为什么更新按钮不起作用的代码可能有什么问题?表单操作和方法不起作用。单击更新按钮后无法加载。对此没有回应。

        <form method="POST" action="monitor/edit.php">
            <input type="hidden" class="form-control" name="id" value="<?php echo $row['id']; ?>">
            <div class="row form-group">
                <div class="col-sm-2">
                    <label class="control-label modal-label">Brand</label>
                </div>
                <div class="col-sm-10">
                    <input type="text" class="form-control" name="monitor_brand" value="<?php echo $row['monitor_brand']; ?>">
                </div>
            </div>
            <div class="row form-group">
                <div class="col-sm-2">
                    <label class="control-label modal-label">Code</label>
                </div>
                <div class="col-sm-10">
                    <input type="text" class="form-control" name="code" value="<?php echo $row['code']; ?>">
                </div>
            </div>
        </div>
        </div>
        <div class="modal-footer">
             <button type="button" data-dismiss="modal" class="btn btn-danger waves-effect">
                <i class="material-icons"></i><span>Cancel</span>
            </button>
            <button type="submit" name="edit" class="btn btn-success waves-effect">
                <i class="material-icons"></i><span>Update</span>
            </button>
        </form>

edit.php中的代码

    <?php
    session_start();
     include_once('../../conn.php');

     if(isset($_POST['edit'])){
    $id = $_POST['id'];
    $monitor_brand = $_POST['monitor_brand'];

    $sql = "UPDATE monitor SET monitor_brand = '$monitor_brand' WHERE id = '$id'";

    //use for MySQLi OOP
    if($conn->query($sql)){
        $_SESSION['success'] = 'Data updated successfully';
    }
    else{
        $_SESSION['error'] = 'Something went wrong in updating data';
    }
      }
       else{
    $_SESSION['error'] = 'Select data to edit first';
      }

      header('location: ../insert_ce.php');

     ?>

我只想让更新按钮起作用。

php forms button
© www.soinside.com 2019 - 2024. All rights reserved.