Php 插入值时重定向不起作用?
视图: 在我看来,我已经为移动验证创建了一个模型。现在,当我把手机号码放入文本框中时,该值将存储到数据库中,但不会重定向。在重定向内部,我使用批量sms进程,通过该进程我将消息发送到客户端。那么,我该怎么做呢?请帮帮我Php 插入值时重定向不起作用?,php,jquery,codeigniter,Php,Jquery,Codeigniter,视图: 在我看来,我已经为移动验证创建了一个模型。现在,当我把手机号码放入文本框中时,该值将存储到数据库中,但不会重定向。在重定向内部,我使用批量sms进程,通过该进程我将消息发送到客户端。那么,我该怎么做呢?请帮帮我 谢谢您正在使用ajax进行移动变体,这就是为什么您不能从那里重定向它 public function mobile_verification() { $data['logg'] = $this->session->userdata('logged_in');
谢谢您正在使用ajax进行移动变体,这就是为什么您不能从那里重定向它
public function mobile_verification()
{
$data['logg'] = $this->session->userdata('logged_in');
$mobile = $this->input->post('mobile');
$uid = $this->input->post('uid');
$password = rand(10,10000);
$data = array(
"uid"=>$uid,
"mobile"=>$mobile,
"password"=>$password,
);
$sql = $this->db->insert('mobile_verify',$data);
if($sql = true)
{
redirect("quiz/verify");
}
else
{
echo "error";
}
}
你的其他部分是否正常工作?只要将if$sql=true更改为if$sql==true,然后再试一次。@ZerozAndOnes仍然不起作用
public function mobile_verification()
{
$data['logg'] = $this->session->userdata('logged_in');
$mobile = $this->input->post('mobile');
$uid = $this->input->post('uid');
$password = rand(10,10000);
$data = array(
"uid"=>$uid,
"mobile"=>$mobile,
"password"=>$password,
);
$sql = $this->db->insert('mobile_verify',$data);
if($sql = true)
{
redirect("quiz/verify");
}
else
{
echo "error";
}
}
$.ajax({
type:"POST",
data:{"mobile":mobile, "uid":uid},
url:"<?php echo base_url(); ?>quiz/mobile_verification",
success:function(data){
window.location.href= '<?php echo base_url(); ?>quiz/verify';//redirect from here or use $.reload() function
}
});