我有一个大问题。我有一个功能,您应该替换“密码”。但是当用户第一次点击提交时,在 var_dump 中留下 Hands = "false"。如果您再次执行相同的过程并且效果很好!有没有类似的问题?
看法:
public function View(){
$NavigationView = New NavigationView();
return "
<div class='change'>
<form name='login' id='RegisterUserForm' method='Post' action='" . $NavigationView -> GetPersonIndex() . "'>
<p>
<label class='label' for='password'><h2 id='changelabel' >New Password</h2></label>
</p>
<p>
<input type='password' size='20' name='$this->pass' id='name' class='text'/>
</p>
<input type='hidden' id='submithidden' value='true' name='" . NavigationView::Personindex . "'/>
<input type='submit' name='submit' id='submit' value='Change Password'/>
</form>
</div>
";
}
控制器 :
if($PersonChangeView->TriedToChangePassword()){
var_dump($PersonChangeView->GetPassword(),$Username);
$kalle = $UserHandler->ChangePassword($PersonChangeView->GetPassword(),$Username);
var_dump($kalle);
}
处理程序:
public function ChangePassword($password,$username){
var_dump($password,$username);
$DBConnection = new DBConnection();
$DBConnection -> Connect();
$sql= "UPDATE user SET m_password=? where m_username=?";
$stmt = $DBConnection -> prepare($sql);
$stmt -> bind_param("ss",$password, $username);
if ($stmt === FALSE) {
//echoBr("prepare of '$sql' failed " . $DBConnection -> error);
return false;
}
$stmt -> execute();
// ger resultet.
$result = $stmt -> get_result();
$stmt -> close();
return false;
}