我有一个示例页面可以重置密码。如果此用户提交此表单,它将显示一条消息,例如“您的密码已成功更新”,并重定向到其他页面。我的脚本怎么了?
public function updatepassword(){
$this->form_validation->set_rules('newpassword','Current Password',
'required|alpha_numeric|min_length[6]|max_length[20]');
$this->form_validation->set_rules('confpassword','Current Password',
'required|alpha_numeric|min_length[6]|max_length[20]');
if($this->form_validation->run()){
$password1 = $this->input->post('newpassword');
$password2 = $this->input->post('confpassword');
$this->load->model('app_model');
$id = $this->session->flashdata('item');;
// die(var_dump($id));
if($password1 == $password2){
if($this->app_model->update_password($password1, $id)){
$this->db->where('email', $id);
$this->db->update('login', array('token' => random_string('alnum',20)));
echo 'Password Sukses Diperbaharui'and redirect('web');//here
}else{
echo 'Password Gagal Diperbaharui';
}
}else{
echo 'Password is not matching';
}
}else{
echo validation_errors();
}
}
答案 0 :(得分:1)
一种可行的方法是使用javascript进行重定向。
将脚本添加到成功页面并设置超时。
<?php
public function updatepassword() {
$this->form_validation->set_rules('newpassword','Current Password', 'required|alpha_numeric|min_length[6]|max_length[20]');
$this->form_validation->set_rules('confpassword','Current Password', 'required|alpha_numeric|min_length[6]|max_length[20]');
if ($this->form_validation->run()) {
$password1 = $this->input->post('newpassword');
$password2 = $this->input->post('confpassword');
$this->load->model('app_model');
$id = $this->session->flashdata('item');;
// die(var_dump($id));
if ($password1 == $password2) {
if ($this->app_model->update_password($password1, $id)) {
$this->db->where('email', $id);
$this->db->update('login', array('token' => random_string('alnum',20)));
// add below codes
?>
Password Sukses Diperbaharui
<script>
setTimeout(() => {
document.location.href = 'web';
}, 3000);
</script>
<?php
// add above codes
} else {
echo 'Password Gagal Diperbaharui';
}
} else {
echo 'Password is not matching';
}
} else {
echo validation_errors();
}
}
?>
答案 1 :(得分:0)
server {
listen 80;
server_name blog.listingnaples.com;
access_log /srv/www/blog.listingnaples.com/logs/access.log;
error_log /srv/www/blog.listingnaples.com/logs/error.log;
location / {
root /srv/www/blog.listingnaples.com;
index index.html index.htm index.php;
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /srv/www/blog.listingnaples.com/$fastcgi_script_name;
}
}
server {
listen 80;
server_name listingnaples.com;
access_log /srv/www/listingnaples.com/logs/access.log;
error_log /srv/www/listingnaples.com/logs/error.log;
location /blog {
proxy_pass https://blog.listingnaples.com;
}
location / {
root /srv/www/listingnaples.com/public;
index index.html index.htm index.php;
try_files $uri $uri/ /index.php?$args;
}
location ~* ^((?!\/blog)(.+)\.php)$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /srv/www/listingnaples.com/public/$fastcgi_script_name;
}
}