Welcome Guest, Not a member yet? Register   Sign In
routes
#1

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');
                                
        }

" If I looks more intelligence please increase my reputation."
Reply
#2

localhost/blog_form

Place the route above the default_controller
Reply
#3

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?
" If I looks more intelligence please increase my reputation."
Reply
#4

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




Theme © iAndrew 2016 - Forum software by © MyBB