我在验证控制器上的会话中保存了一些数据,然后我将此会话数据提取到user_activity模型中,并将会话数据插入到活动表中.我的问题是只保存在会话中的用户名数据,我可以在模型上提取会话后获取并仅插入用户名数据.我是Codeigniter的新手.因此,找出问题非常困难.我想好几天才发现问题.但不幸的是我做不到.所以,请任何人帮助我.谢谢
VerifyLogin控制器:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
session_start();
class VerifyLogin extends CI_Controller {
function __construct()
{
parent::__construct();
$this->load->model('user','',TRUE);
$this->load->model('user_activity','',TRUE);
}
function index()
{
//This method will have the credentials validation
$this->load->library('form_validation');
$this->form_validation->set_rules('username', 'Username', 'trim|required|xss_clean');
$this->form_validation->set_rules('password', 'Password', 'trim|required|xss_clean|callback_check_database');
if($this->form_validation->run() == FALSE)
{
//Field validation failed. User redirected to login page
$this->load->view('login_view');
}
else
{
//Go to private area
redirect('home', 'refresh');
}
}
function check_database($password)
{
//Field validation succeeded. Validate against database
$username = $this->input->post('username');
$vercode = …Run Code Online (Sandbox Code Playgroud) 我在JavaScript中使用Modernizr媒体查询来更改元素边距并添加"小"类.当我调整浏览器大小时,我的Modernizr媒体查询不起作用,但是当我刷新页面时,它可以工作.我知道我可以使用jQuery $( window ).resize()函数解决这个问题,但我想用媒体查询来解决它.任何人都能告诉我如何解决这个问题吗?
<html class="no-js">
<head>
<title>Foundation 5</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="modernizr.js"></script>
<script type="text/javascript">
$(document).ready(function() {
if (Modernizr.mq('(max-width: 767px)')) {
$("#secondary").addClass("small");
$("#secondary").css("margin", " 25px");
}
});
</script>
<style type="text/css">
#primary {
width: 300px;
height: 200px;
background-color: black;
}
#secondary {
margin: 0 auto;
width: 250px;
height: 150px;
background-color: white;
position: absolute;
}
</style>
</head>
<body>
<div id="primary">
<div id="secondary">
</div>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)