我在Jquery Ajax中使用CodeIgniter3将一些数据插入数据库。
但是,当用户插入以下内容时,我使用csrf_token制作了安全表单数据。
问题我无法在Chrome浏览器上将数据插入数据库,但可以在Firefox中使用。
错误 403禁止和
<div id="container">
<h1>An Error Was Encountered</h1>
<p>The action you have requested is not allowed.</p> </div>
</body>
Run Code Online (Sandbox Code Playgroud)
这是我在配置文件中的配置:
$config['global_xss_filtering'] = TRUE;
$config['csrf_protection'] = TRUE;
$config['csrf_regeneration'] = TRUE;
$config['csrf_token_name'] = 'csrf_token_name';
$config['csrf_cookie_name'] = 'csrf_cookie_name';
$config['csrf_exclude_uris'] = array();
$config['csrf_expire'] = 7200;
Run Code Online (Sandbox Code Playgroud)
我用控制器将一些数据插入数据库
public function post() {
$new_token = $this->security->get_csrf_hash();
$this->form_validation->set_rules($this->ads_m->post_rule);
if ($this->form_validation->run() == FALSE) {
echo json_encode(array('res' => FALSE));
} else {
$data = array(
'name' => $this->input->post("p_name"),
'user_id' …Run Code Online (Sandbox Code Playgroud) 我使用CodeIgniter 3.0.0和PHP 5.6.
昨天我更新到PHP 7并开始收到以下错误: -
Uncaught TypeError: Argument 1 passed to CI_Exceptions::show_exception() must be
an instance of Exception, instance of Error given, called in /my/file/path/app/system/core/Common.php on line 658 and defined in /my/file/path/hgx_portal/app/system/core/Exceptions.php:190
Stack trace:
#0 /my/file/path/hgx_portal/app/system/core/Common.php(658): CI_Exceptions->show_exception(Object
(Error))
#1 [internal function]: _exception_handler(Object(Error))
#2 {main}
thrown in /my/file/path/hgx_portal/app/system/core/Exceptions.phpon line 190
Run Code Online (Sandbox Code Playgroud) 我正在处理事务,并且在提到的代码中我遇到了一些问题.我没有提交事务,但是它将数据插入到我的数据库中.
$this->db->trans_begin();
$this->db->insert('tblorder',$data);
$orderid=$this->db->insert_id();
foreach ($orderItemList as $orderItemList) {
$orderitem = array('orderid' =>$orderid ,'productid' =>$orderItemList->productid ,'amount' =>$orderItemList->amount);
$this->db->insert('tblorderitem',$orderitem);
}
$this->db->trans_complete();
if ($this->db->trans_status() == 1) {
$this->db->trans_rollback();
return "true";
} else {
$this->db->trans_commit();
return "false";
}
Run Code Online (Sandbox Code Playgroud)
我回滚了事务,并且所有数据都被插入到我的数据库中.一定是什么问题?我无法得到它.
我想以这样的方式制作输入文本字段,它会阻止文本输入字段中的表情符号输入。我已经通过传递对特定路线的控制器进行了验证。这是阻止表情符号的正确方法。
控制器代码。
$this->form_validation->set_rules('registration', 'Registration', 'required|alpha_numeric');
$this->form_validation->set_rules('odometer', 'Odometer', 'required|alpha_numeric');
Run Code Online (Sandbox Code Playgroud)
查看代码:
<input type="text" name="odometer" placeholder="Odometer" class="form-control profileControl odometer required number" id="odometer-<?php echo $vehicle_count; ?>" value="<?php echo $vehicle->intCarOdometer ?>"/>
<input type="text" placeholder="Registration" name="registration" class="form-control profileControl registration required" id="registration-<?php echo $vehicle_count; ?>" value="<?php echo $vehicle->vchCarRegistration ?>" pattern="[a-zA-Z0-9]+"/>
Run Code Online (Sandbox Code Playgroud) 在 Codeigniter 中使用这个 HMVC 插件。( https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/src/codeigniter-3.x/ )
在另一台服务器上运行良好,但在这台服务器上我收到此错误!
A PHP Error was encountered
Severity: 8192
Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior
Filename: MX/Router.php
Line Number: 239
Backtrace:
File: /var/www/project.test/public/application/third_party/MX/Router.php
Line: 239
Function: strpos
File: /var/www/project.test/public/application/third_party/MX/Router.php
Line: 101
Function: _set_default_controller
File: /var/www/project.test/public/index.php
Line: 324
Function: require_once
Run Code Online (Sandbox Code Playgroud) 我是Codeigniter,我需要为用户提供动态语言。
我在标题上添加了下拉菜单,我希望允许用户更改前端的网站语言。
我试图在一个控制器中使用以下代码更改语言
$this->config->set_item('language','spanish');
Run Code Online (Sandbox Code Playgroud)
但它不起作用,语言不变
我也尝试在我的控制器之一中使用以下代码进行会话
$mylanguage = $this->session->set_userdata(array('my_language',$dynamiclang));
Run Code Online (Sandbox Code Playgroud)
并尝试在配置文件中访问此变量,但它也无法正常工作。
帮我做这个工作。
我试图跟着YouTube上的笨tutorail 这里关于笨创建迁移.但是,我收到了错误
版本号无法找到迁移:1
我已经设置了$ config ['migration_version'] = 1 ; 在Application/Config/migration.php和我的用于创建用户表的迁移文件中
应用程序/迁移/ 001_Create_User.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Migration_Create_Users extends CI_Migration {
/*
up function is for creating and alert table
*/
public function up()
{
$this->dbforge->add_field(array(
'id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'auto_increment' => TRUE
),
'email' => array(
'type' => 'VARCHAR',
'constraint' => '128',
),
'password' => array(
'type' => 'VARCHAR',
'constraint' => '100',
),
));
$this->dbforge->add_key('id',TRUE); …Run Code Online (Sandbox Code Playgroud) 我是新手,laravel它对编码有好处,但速度并不快codeigniter
我使用codeigniter它的页面加载小于5MB但laravel页面加载可能与8MB相同.我想与之合作,laravel但我需要建议,以便laravel加快速度codeigniter
我使用Codeigniter 3构建了一个系统,出于某种原因,只有一些用户正在使用白屏.我正在尝试调试它并且已启用日志记录.
我的日志中出现以下错误:
Severity: Notice --> Use of undefined constant VIEWPATH - assumed 'VIEWPATH' /my/server/path/to/system/core/Common.php 196
Severity: Notice --> Use of undefined constant VIEWPATH - assumed 'VIEWPATH' /my/server/path/to/system/core/Exceptions.php 162
Severity: Warning --> include(): Failed opening 'VIEWPATHerrors/html/error_general.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') /my/server/path/to/system/core/Exceptions.php 182
Run Code Online (Sandbox Code Playgroud)
所以似乎核心php文件无法从索引文件中看到已定义的变量.但奇怪的是,如果我在Common.php的顶部定义VIEWPATH,则表示已经设置了VIEWPATH.我在控制器中添加了一个log_message来输出我的VIEWPATH设置,它似乎工作正常.
我无法弄清楚如何克服这个问题.有任何想法吗?
<div class="col-md-6">
<label class="control-label"><span class="text-danger">*</span>Journey Days</label>
<div class="form-group">
<input type="number" name="day" class="form-control" >
<?php echo $this->input->post('day');?> </input>
<span class="text-danger"> <?php echo form_error('day');?></span>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
如果设置了name ="day"值,那么我怎样才能得到这一天的值?我想这样做,
<?php
if (isset($day))
{ print $day ; }
else { print " day is not set " ;} ?>
Run Code Online (Sandbox Code Playgroud) codeigniter-3 ×10
php ×7
codeigniter ×5
ajax ×1
hmvc ×1
html ×1
jquery ×1
laravel ×1
laravel-5.1 ×1
mysql ×1
php-7 ×1
transactions ×1