我很困,因为我仍然不知道如何从下面的代码中应用Sweetalert。
登录视图:
<form id="formlogin" action="<?=site_url('auth/process')?>" method="post">
<div class="form-group has-feedback">
<input type="text" id="name" name="username" class="form-control" placeholder="Username" autofocus required>
<span class="glyphicon glyphicon-user form-control-feedback"></span>
</div>
<div class="form-group has-feedback">
<input type="password" id="password" name="password" class="form-control" placeholder="Password" required>
<span class="glyphicon glyphicon-lock form-control-feedback"></span>
</div>
<div class="row">
<div class="col-xs-8">
<a style="vertical-align:middle; line-height:40px" href="<?=site_url('account')?>" class="text-center">Register a new account</a>
</div>
<div class="col-xs-4">
<button type="submit" name="login" class="btn btn-primary btn-block btn-flat">Sign In</button>
</div>
</div>
</form>
登录过程控制器:
public function process()
{
$post = $this->input->post(null, TRUE);
//print_r ($post);
if( isset ( $post['login'] ) ) {
$this->load->model('user_m');
$query = $this->user_m->login($post);
if ($query->num_rows() > 0) {
//echo "Login process success";
$row = $query->row();
// echo $row->username;
$params = array(
'userid' => $row->id_user,
'level' => $row->level,
);
$this->session->set_userdata($params);
echo "<script>
alert ('Login Success');
</script>";
} else {
echo "<script>
alert ('Login Fail');
</script>";
}
}
}
在Codeigniter中用户成功登录后,如何更改以使用Sweetalert而不是正常警报?