我正在使用 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>我想更新我的数据库
2 回答
扬帆大鱼
TA贡献1799条经验 获得超9个赞
首先提到下面的表单方法并使用csrf令牌@csrf
为什么你不能使用控制器来完成这项工作首先使用控制器,然后制作一个更新信息的方法
public function update_user(Request $request){
if ($request->isMethod('post')) {
$data = $request->all();
User = new User();
$voornaam = $_POST['voornaam'];
$achternaam = $data['achternaam'];
$gebruikersnaam = $data['gebruikersnaam'];
$telefoonnummer = $data['telefoonnummer'];
$email = $data['email'];enter code here
}
}
- 2 回答
- 0 关注
- 108 浏览
添加回答
举报
0/150
提交
取消