所以,当我有一个像这样的选择形式时:
<form method="post" action="" name="change_slider">
<label class="control-label"><?php echo $LANG['admin']['global']['Slider']; ?></label>
<div class="controls">
<select name="slider">
<option name="sex" value="false">none</option>
<option name="sex" value="poepCru3er">Cru3er</option>
</select>
</div>
<div class="form-actions">
<button type="submit" name="slideredit" class="btn btn-primary"><?php echo $LANG['admin']['global']['submit']; ?></button>
</div>
</form>
我希望我的数据库中的选定值可以这样做:
if(isset($_POST['change_slider'])) {
$name = $_POST['slider'];
$errorsslide = $users->changeSlider($name);
}
因为它不起作用。顺便说一句,这是changeSlider
函数,如果有必要的话
public function changeSlider($name) {
$errorsslide = array();
$stmt = $this->mysqli->prepare("UPDATE cms_funtions SET value=? WHERE title='Slider'");
$stmt->bind_param('s', $name);
$stmt->execute();
$stmt->close();
$errorsslide[] = "<div class='alert alert-success'><button type='button' class='close' data-dismiss='alert'>x</button><strong>Success!</strong> Slider Changed successfully!</div>";
return $errorsslide;
}
所以,长话短说,我希望表格的选定值进入我的数据库。
有人看到我的错误吗?
答案 0 :(得分:1)
没有名为change_slider
的表单字段,因此此后的代码将永远不会运行,因为条件始终为false:
if(isset($_POST['change_slider'])) {
您应该将其更改为:
if($_SERVER['REQUEST_METHOD'] === 'POST') {