CodeIgniter Forums
routes - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: routes (/thread-65021.html)



routes - davy_yg - 04-21-2016

Hello,

I am trying to access views/blog_form.php but do not know what to type in the url to access that.  Can anyone explain how to?

I can access blog by typing localhost/blog but not the next one.


routes.php



PHP Code:
$route['default_controller'] = 'blog';
$route['blog_form'] = 'blog/blog_form'



controllers/Blog.php


PHP Code:
class Blog extends CI_Controller {

 
       public function index()
 
       {
 
               $this->load->model('blog_model');

 
               //$data['query'] = $this->blog->insert();

                
$data['title'] = $this->blog_model->select_blog();
                
$data['content'] = $this->blog_model->select_blog();
                
$data['date'] = $this->blog_model->select_blog();
                
                
$this->load->view('blog'$data);
                                            
                
//$this->load->view('blog');
 
       
        
}
        
        public function 
blog_form()
        {
                
$this->load->view('blog_form');
                                
        }




RE: routes - paulkd - 04-21-2016

localhost/blog_form

Place the route above the default_controller


RE: routes - davy_yg - 04-25-2016

I did place the routes above the config/routes.php


routes.php

PHP Code:
$route['blog_form'] = 'blog/blog_form';
$route['default_controller'] = 'blog/blog_form';

$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE


views/blog_form.php

PHP Code:
<html>

<
title>Blog Form</title>

<
br>

<
h1>BLOG FORM</h1>


<?
php echo validation_errors(); ?>

<?php echo form_open('form'); ?>


<table>

<tr>
<td>Date  :</td>
<td><input type="text" name="username" value="" size="50" /></td>
</tr>
<tr>
<td>Upload  :<br><br></td>
<td><input type="text" name="username" value="" size="50" /></td>
</tr>
<tr>
<td>Title :</td>
<td><input type="text" name="username" value="" size="50" /></td>
</tr>
<tr>
<td>Content :</td>
<td><input type="text" name="username" value="" size="50" /></td>
</tr>

<div><input type="submit" value="Submit" /></div>

</form>
</table>


</html> 


I still have:


BLOG FORM

Fatal error: Call to undefined function validation_errors() in C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\blog\application\views\blog_form.php on line 11
A PHP Error was encountered
Severity: Error
Message: Call to undefined function validation_errors()
Filename: views/blog_form.php
Line Number: 11
Backtrace:


line 11:  <?php echo validation_errors(); ?>

How fix the error?


RE: routes - hipm - 04-25-2016

Load this helper: $this->load->helper('form');