- 已修复 -
当我提交表单时,我想要在表中编辑的行强制为 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');
}
最佳答案
我找到了解决方案!它在我的 define('BASE_URL', 'https://monkstudio.biz/');
因为我在 .htaccess 中的网站链接带有“www”,所以在脚本中它没有设置,现在我把 define('BASE_URL', 'https://www.monkstudio.biz/') ;
并且工作正常!
我很自豪我自己发现了这个。
关于php - $_POST 在第二页上不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46229806/