我有一个控制器,我需要检查URL中的有效ID,show_404()如果ID不匹配.
我面临的问题是,当我调用show_404()它时只显示view/error/404.html而不是my404我配置的自定义控制器routes.php
差异是my404控制器添加页眉和页脚相同view/error/404.html
我有CodeIgniter3的问题:找不到404页面
文件:application/controllers/Welcome.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Welcome extends CI_Controller {
public function __construct()
{
parent::__construct();
}
public function index()
{
$this->load->view('Welcome_Page');
}
public function tutorial()
{
$this->load->view('Tutorial_Page');
}
public function manual()
{
$this->load->view('Manual_Page');
}
public function forum()
{
$this->load->view('Forum_Page');
}
public function register()
{
$this->load->view('Register_Page');
}
public function login()
{
$this->load->view('Login_Page');
}
}
Run Code Online (Sandbox Code Playgroud)
文件:application/config/autoload/php
$autoload['helper'] = array('url');
Run Code Online (Sandbox Code Playgroud)
文件:application/config/routes.php
$route['default_controller'] = 'welcome';
$route['translate_uri_dashes'] = FALSE;
Run Code Online (Sandbox Code Playgroud)
文件:application/config/config.php
$config['base_url'] = 'http://subdomain.domain.tld';
$config['index_page'] = '';
Run Code Online (Sandbox Code Playgroud)
文件:.htaccess
RewriteEngine On
RewriteCond …Run Code Online (Sandbox Code Playgroud) php model-view-controller .htaccess codeigniter codeigniter-3
亲爱的:帮助我在wamp本地服务器上运行工作正常但我有问题My_Controller未找到是核心文件夹.我已经在核心文件夹中插入了My_Controller,"core/My_Controller.php"在config.php中我已经插入了配置,"$config['subclass_prefix'] = 'MY_';"任何人都可以帮助我吗?
Fatal error: Class 'MY_Controller' not found in /home/phnompen/public_html/my_side_url/application/controllers/Controller.php on line 9
A PHP Error was encountered
Severity: Error
Message: Class 'MY_Controller' not found
Filename: controllers/Controller.php
Line Number: 9
Backtrace:
Run Code Online (Sandbox Code Playgroud) 我正在尝试在 codeigniter 3 中加载自定义配置
$this->config->load('test')
Run Code Online (Sandbox Code Playgroud)
test.php 文件在application/config包含以下内容的文件夹中可用。
<?php
$config['item_test']='sample config item';
Run Code Online (Sandbox Code Playgroud)
我会收到以下错误
配置文件 test.php 不存在。
Codeigniter 版本:3.1.0
我想不出实现结束日期总是大于开始日期的逻辑。这是我的视图代码,其中有两个字段“事件结束”和“事件开始”。尝试执行,如验证中所示,使用jQuery结束日期大于开始日期,但失败。如何实现呢?
<div class="clearfix"></div>
<div class="control-group form-group">
<label class="control-label col-md-4" style="text-align:left">Event Start</label>
<div class="controls" style="margin-left:0px">
<div class="col-md-3 date" data-date="12-02-2012" data-date-format="dd-mm-yyyy" data-date-viewmode="years">
<input class="m-wrap col-md-11 m-ctrl-medium datepicker form-control" required="required" name="starttimedate" id="ed_starttimedate" type="text" value="<?php echo $_POST['starttime']?date('d-m-Y',$_POST['starttime']):date('d-m-Y'); ?> " />
<!-- <span class="add-on"><i class="fa fa-calendar" style="margin-top:5px"></i></span> -->
</div>
<div class="col-md-1"> </div>
<div class="col-md-3 bootstrap-timepicker-component">
<input class="m-wrap col-md-11 m-ctrl-medium timepicker-default form-control" required="required" value="<?php echo date('h:i A',$_POST['starttime']);?>" name="starttimetime" id="ed_starttimetime" type="text" />
<!-- <span class="add-on"><i class="fa fa-clock-o" style="margin-top:5px"></i></span>-->
</div>
<div class="clearfix"></div>
</div>
</div>
<div …Run Code Online (Sandbox Code Playgroud)登录后如何将用户重定向到当前页面?
用户在
domain.com/article/news-18565点击登录按钮后正在此 URL 上阅读新闻,然后我如何domain.com/login在登录用户之前和之后获取 currenturl()domain.com/article/news-18565
表单.html
<form action="signin" method="post" accept-charset="utf-8">
<div class="form-group">
<label for="">Email:</label>
<input type="text" name="email" value="" class="form-control form-control-lg">
</div>
<div class="form-group">
<label for="">Password:</label>
<input type="password" name="password" value="" class="form-control form-control-lg">
</div>
<div class="form-group">
<input type="submit" name="submit" value="Sign in to your account" class="float-md-right btn btn-primary">
</div>
</form>
Run Code Online (Sandbox Code Playgroud)
控制器.php
function index(){
$user_profile = 'user';
$this->authModel->loggedin() == FALSE || redirect($user_profile);
$rules = $this->authModel->rules;
$this->form_validation->set_rules($rules);
if($this->form_validation->run() == TRUE){
if($this->authModel->login() == TRUE){
redirect($user_profile);
}else{
$this->session->set_flashdata('error', 'That email/password combination does …Run Code Online (Sandbox Code Playgroud) 我使用Backbone.js实现了一个简单的登录系统.
我试图使用HTTP POST方法将用户名和密码传递给处理用户身份验证的Controller类.
public function sessions() {
if ($this->input->server('REQUEST_METHOD') == 'POST') {
$this->login();
} elseif ($this->input->server('REQUEST_METHOD') == 'GET') {
$this->index();
} elseif ($this->input->server('REQUEST_METHOD') == 'DELETE') {
$this->session->sess_destroy();
$this->index();
}
}
Run Code Online (Sandbox Code Playgroud)
Backbone.js代码段:
$(document).ready(function() {
var Session = Backbone.Model.extend({
url: function() {
var link = "http://<?php echo gethostname(); ?>/reddit/index.php/welcome/sessions";
return link;
},
defaults: {
username: null,
password: null
}
});
var model = new Session();
var DisplayView = Backbone.View.extend({
el: ".complete",
model: model,
type: 'POST',
initialize: function() {
this.listenTo(this.model, "sync change", this.gotdata); …Run Code Online (Sandbox Code Playgroud) 您好我正在使用Codeigniter,我想生成随机密码.
我开发了注册功能
crypt($password)
Run Code Online (Sandbox Code Playgroud)
登录功能检查密码如下.
if (crypt($password, $hashed_password) === $hashed_password)
{
return $query->result();
}
Run Code Online (Sandbox Code Playgroud)
我正在开发忘记功能.
如何将随机生成的密码发送到用户邮件当我使用crypt()登录时.
我对 PHPWord 有一个问题,我相信版本是 0.11.0,我使用 PHPWord for CI。
问题是我找不到合适的 php 脚本来制作下划线,这是我得到的最新脚本,
$section->addText(
$text,
[ 'underline' => \PhpOffice\PhpWord\Style\AbstractStyle::UNDERLINE_SINGLE ], // Problem with this line
[ 'align' => \PhpOffice\PhpWord\Style\Alignment::ALIGN_CENTER ] // This one fine
);
Run Code Online (Sandbox Code Playgroud)
但是每当我得到脚本时,它总是显示错误或没有给我想要的东西,(带下划线的文本)。
这是我得到的错误
遇到未捕获的异常
类型:错误
消息:未定义的类常量“UNDERLINE_SINGLE”
文件名:C:\xampp\htdocs\test\application\controllers\Print.php
行号:47
回溯:
文件:C:\xampp\htdocs\test\index.php 行:315 功能:require_once
我感谢任何帮助,提前致谢。
该应用程序的Codeigniter版本为3.1.3。当构建此应用程序时,可以与此htaccess文件一起正常工作,但是今天当我运行此应用程序并遇到此类错误时。
当运行我的codeigniter网站时,htaccess文件无法重写我的index.php网址。因此,未显示请求的URL错误。
正常工作的URL => localhost / Magpie / index.php / Front_master / aboutus.html
错误网址 => localhost / Magpie / index.php / Front_master / aboutus.html
这是我的htaccess代码:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /Magpie/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Run Code Online (Sandbox Code Playgroud)
控制器文件:Front_master.php
<?php
class Front_master extends CI_Controller {
public $result = array();
public function __construct() {
parent::__construct();
//load models
$this->result["getContact"] = $this->GetInformation->getContact();
$this->result["getLogo"] = $this->GetInformation->getLogo();
$this->result["getSlide"] = $this->GetInformation->getSlide();
$this->result["getServices"] = $this->GetInformation->getServices();
$this->result["getContent"] = $this->GetInformation->getContent();
$this->result["getPropertyListing"] = $this->GetInformation->getPropertyListing();
$this->result["getBestDeal"] …Run Code Online (Sandbox Code Playgroud) codeigniter-3 ×10
php ×7
codeigniter ×5
.htaccess ×2
javascript ×2
backbone.js ×1
jquery ×1
login ×1
phpoffice ×1
phpword ×1
ubuntu-16.04 ×1