php - $_POST 在第二页上不起作用

标签 php mysql post

- 已修复 -

当我提交表单时,我想要在表中编辑的行强制为 0,而不是设置 0 或 1(当我切换时)。这意味着表(行)以某种方式获取值 0。

这是我的表格:

<form class="form-horizontal" action="<?php echo BASE_URL?>process.php?task=edit_notify" method="post">
    <div class="form-group">
        <div class="material-switch pull-left">
            <p><span class="control-label" style="color: rgba(75, 75, 75, 0.6); cursor: default;"><?php echo ADMIN_NOTIFY; ?></span></p>
            <input id="allow_reg_msg" name="allow_reg_msg" type="checkbox" value="1" <?php if($row['allow_reg_msg'] == 1) echo "checked='checked'"; ?> />
            <label for="allow_reg_msg" class="label-primary"></label>
        </div>
    </div></br>
    <div class="form-group">
        <button type="submit" class="btn_"><i class="fa fa-pencil"></i> <?php echo EDIT; ?></button>
    </div>
</form>

当我提交时,它应该将值发送到process.php页面,这里是“process.php?task=edit_notify”:

if(isset($_GET['task']) && $_GET['task'] == "edit_notify"){
    if(!$user->isLoggedIn()) Redirect::to('index');
    if(!$user->hasPermission('admin')) Redirect::to('index');
    $allow_reg_msg = $_POST['allow_reg_msg'];
    $sql = "UPDATE `settings` SET 
        `allow_reg_msg` = :allow_reg_msg
    WHERE `id` = 1";
    $query = $handler->prepare($sql);
    $query->execute(array(
        ":allow_reg_msg" => $allow_reg_msg
    ));
    Session::flash('edit_site_success', SUCCESS_UPDATE);
    Redirect::to('admin/index.php?page=edit_site');
}

这里是我的数据库中的一些图像: image 1 , image 2

最佳答案

我找到了解决方案!它在我的 define('BASE_URL', 'https://monkstudio.biz/');

因为我在 .htaccess 中的网站链接带有“www”,所以在脚本中它没有设置,现在我把 define('BASE_URL', 'https://www.monkstudio.biz/') ; 并且工作正常!

我很自豪我自己发现了这个。

关于php - $_POST 在第二页上不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46229806/

相关文章:

php - Mysql时区和从一天中选择行

php - SQLSTATE[42S22] : Column not found: 1054 Unknown column '$Valuess' in 'field list' '

php - 如果记录存在则添加到记录,否则创建记录

mysql - 如何使用 Node.js 和 Sequelize 设置基于角色的身份验证 API?

post - 带有 POST 请求的 Yii 2 中的 Pjax

php - 从 Mysql 导出 CSV

MySQL 分别select WHERE a IN (..) AND b IN (..)

mysql - 主键应该始终是无符号的?

Python urllib POST 响应

使用 Golang 发布 HTML 表单方法