我正在尝试从POST方法中选择数据,而回声除外,只有一次会停止所有显示。
<div>
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Update User Profile</h5>
<button class="close" type="button" data-dismiss="modal" aria-label="Close">
</button>
</div>
<div class="modal-body">
<form class="user" method="post">
<div class="form-group row">
<div class="col-sm-6 mb-3 mb-sm-0">
<input type="text" class="form-control form-control-user" name="first_name" value="<?php echo $firstname; ?>">
</div>
<div class="col-sm-6">
<input type="text" class="form-control form-control-user" name="first_name" value="<?php echo $lastname; ?>">
</div>
</div>
<div class="form-group">
<input type="email" class="form-control form-control-user" name="user_email" value="<?php echo $email; ?>">
</div>
<div class="form-group">
<input type="number" class="form-control form-control-user" name="user_phone" value="<?php echo $phone; ?>">
</div>
<div class="form-group row">
<div class="col-sm-6 mb-3 mb-sm-0">
<input type="password" class="form-control form-control-user" name="password" placeholder="Password">
</div>
<div class="col-sm-6">
<input type="password" class="form-control form-control-user" name="confirmPassword" placeholder="Confirm Password">
</div>
</div>
</div>
<div class="modal-footer">
<a class="btn btn-secondary" href="charts.php">Back to List</a>
<button class="btn btn-primary" name="update-user-profile" href="">Update Profile</button>
</div>
</div>
</div>
<?php
if(isset($_POST['update-user-profile'])){
$updateFirstname = $_POST['first_name'];
$updateLastname = $_POST['last_name'];
$updateUserEmail = $_POST['user_email'];
$updateUserPhone = $_POST['user_phone'];
$newPassword = $_POST['password'];
$newConfirmPassword = $_POST['confirmPassword'];
echo $updateFirstname."<br/>";
echo $updateLastname."<br/>";
echo $updateUserEmail."<br/>";
echo $updateUserPhone."<br/>";
}
?>
答案 0 :(得分:0)
首先,您尚未使用<form></form>
标签。
您已经使用了名字为firstname的输入两次,因此没有得到lastname选项。
<div class="col-sm-6 mb-3 mb-sm-0">
<input type="text" class="form-control form-control-user" name="first_name" value="<?php echo $firstname; ?>">
</div>
<div class="col-sm-6">
<input type="text" class="form-control form-control-user" name="last_name" value="<?php echo $lastname; ?>">
</div>
在上面的代码中,我将first_name更改为last_name。因此,如果您进行更改,那么整个过程都应该起作用。