php - 如何使用下面的代码使我的更新查询工作
问题描述
我正在使用 php 和一些 laravel 设置更新配置文件页面。我有一个 if 检查来检查表单是否已提交并且我有一个更新查询。
更新查询仅适用于 if 语句之外,我不知道为什么。如果我放入 if 语句中,它不会做任何事情。我检查了所有名称是否与我的 sql 数据库中的名称相同并且它们都是正确的。
<form class="form" id="registrationForm">
<div class="form-group">
<div class="col-xs-6">
<label for="first_name">
<h4>Voornaam</h4></label>
<input type="text" class="form-control" name="voornaam" id="first_name" placeholder="<?= $user->voornaam; ?>" title="enter your first name if any.">
</div>
</div>
<div class="form-group">
<div class="col-xs-6">
<label for="last_name">
<h4>Achternaam</h4></label>
<input type="text" class="form-control" name="achternaam" id="last_name" placeholder="<?= $user->achternaam; ?>" title="enter your last name if any.">
</div>
</div>
<div class="form-group">
<div class="col-xs-6">
<label for="phone">
<h4>Gebruikersnaam</h4></label>
<input type="text" class="form-control" name="gebruikersnaam" id="username" placeholder="<?= $user->gebruikersnaam; ?>" title="enter your phone number if any.">
</div>
</div>
<div class="form-group">
<div class="col-xs-6">
<label for="mobile">
<h4>Telefoon nummer</h4></label>
<input type="text" class="form-control" name="telefoonnummer" id="mobile" placeholder="<?= $user->telefoonnummer; ?>" title="enter your mobile number if any.">
</div>
</div>
<div class="form-group">
<div class="col-xs-12">
<label for="email">
<h4>Email</h4></label>
<input type="email" class="form-control" name="email" id="email" placeholder="<?= $user->email; ?>" title="enter your email.">
</div>
</div>
<div class="form-group">
<div class="col-xs-12">
<br>
<button class="btn btn-lg btn-success" type="submit" name="submit"><i class="glyphicon glyphicon-ok-sign"></i> Sla op</button>
<button class="btn btn-lg" type="reset" name="resetww"><i class="glyphicon glyphicon-repeat"></i> Verander wachtwoord</button>
</div>
</div>
</form>
<?php
if (isset($_POST['submit'])) {
$voornaam = $_POST['voornaam'];
$achternaam = $_POST['achternaam'];
$gebruikersnaam = $_POST['gebruikersnaam'];
$telefoonnummer = $_POST['telefoonnummer'];
$email = $_POST['email'];
App\User::where('klant_id', 1)->update(['gebruikersnaam' => $gebruikersnaam, 'voornaam' => $voornaam, 'achternaam' => $achternaam, 'email' => $email ,'telefoonnummer' => $telefoonnummer]);
}
?>
我希望更新我的数据库
解决方案
将标签放在您的表单中,PHP 正在尝试查找 de POST 但您没有发送它。
方法="发布"
推荐阅读
- javascript - 如何为Javascript的变量制作动态字符串
- javascript - 根据过滤器输入更改排序顺序
- regex - 正则表达式:获取键值对格式的值
- ruby-on-rails - 删除所有选中的项目 rails
- corda - Corda - IllegalArgumentException 不知道派对
- javascript - Excel JS API:使用自定义函数从单元格中写入、计算和加载值
- html - 搜索框和按钮不在同一行显示
- laravel - 将数据添加到 Laravel 数据透视表
- c - 何时在 C 中键入 cast malloc
- python-3.x - Python时区转换将分钟添加到小时?