• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
problem of link [solved problem]

#1
Hello
here my difficulty:
I want to establish a link towards another view with this code:

PHP Code:
<H2 class="centrage"><A href="<?php echo site_url('Curriculum'); ?>">Contactez moi !</A></H2

I have an error 404

here the file //controllers/Homepage.php ( principal controller)
PHP Code:
<?php
defined
('BASEPATH') OR exit('No direct script access allowed');

class 
Homepage extends CI_Controller {

 
   public function index()
 
   {
 
       $data['title']= 'Accueil';

 
       $this->load->view('Connon/Header.php',$data);
 
       $this->load->view('Connon/Menu.php');
 
       $this->load->view('Site/Accueil.php');
 
       $this->load->view('Connon/Footer.php');
 
   }

 
   public function curriculum()
 
   {
 
       $data['title']= 'Curriculum';
 
       $this->load->view('Connon/Header.php',$data);
 
       $this->load->view('Connon/Menu.php');
 
       $this->load->view('Site/Curriculum.php');
 
       $this->load->view('Connon/Footer.php');
 
   }




and here the file /config/config.php


PHP Code:
<?php
defined
('BASEPATH') OR exit('No direct script access allowed');

/*
|--------------------------------------------------------------------------
| Base Site URL
|--------------------------------------------------------------------------
|
| URL to your CodeIgniter root. Typically this will be your base URL,
| WITH a trailing slash:
|
|    http://example.com/
|
| WARNING: You MUST set this value!
|
| If it is not set, then CodeIgniter will try guess the protocol and path
| your installation, but due to security concerns the hostname will be set
| to $_SERVER['SERVER_ADDR'] if available, or localhost otherwise.
| The auto-detection mechanism exists only for convenience during
| development and MUST NOT be used in production!
|
| If you need to allow multiple domains, remember that this file is still
| a PHP script and you can easily do that on your own.
|
*/
$root "http://".$_SERVER['HTTP_HOST'];
$root .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);

//$config['base_url']    = "$root";
$config['base_url'   "http://127.0.0.1/codeigniter";

/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['index_page'] = '';

/* 

I use codeigniter 3

thank you for your assistance
French citizen (please excuse me for my english Confused )
Having a good knowledge of the PHP but novice with CodeIgniter
I use CodeIgniter 3



Reply

#2
In simple english, your link is trying to access the controller 'Curriculum'!!

Since 'Curriculum is a method of 'Homepage' controller, your link should be:

PHP Code:
<h2 class="centrage"><a href="<?php echo site_url('homepage/curriculum'); ?>">Contactez moi !</a></h2
Reply

#3
Try this

Code:
<H2 class="centrage"><A href="<?php echo site_url('homepage/curriculum'); ?>">Contactez moi !</A></H2>

Or, since the "URL Helper" seems to be  loaded

Code:
<H2 class="centrage"><?php echo anchor('homepage/curriculum', "Contactez moi !"); ?></H2>
Reply

#4
Make sure you autoload the url helper in config.php.

The link should be:
PHP Code:
<h2 class="centrage"><?php echo anchor('homepage/curriculum','Contactez moi !');?></h2> 

So, include the controller name, followed by the method in the controller.
Only use lowercase in links to controller/methods.
Also avoid uppercase for html tags.
Reply

#5
hello
thank you for your assistance.
but method:
PHP Code:
<h2 class="centrage"><?php echo anchor('homepage/curriculum','Contactez moi !');?></h2> 

give me URL following: http://127.0.0.1/codeigniter/homepage/curriculum is the error 404
French citizen (please excuse me for my english Confused )
Having a good knowledge of the PHP but novice with CodeIgniter
I use CodeIgniter 3



Reply

#6
otherwise if I employ

PHP Code:
<h2 class="centrage"><?php echo anchor('curriculum','Contactez moi !');?></h2> 


I have like answer

"Not Found
The requested URL /codeigniter/curriculum was not found on this server.

Apache/2.4.17 (Win64) PHP/7.0.0 Server at 127.0.0.1 Port 80
Reply

#7
I have a suspicion so please humor me: What happens if you use this?

PHP Code:
<h2 class="centrage"><a href="http://127.0.0.1/codeigniter/index.php/homepage/curriculum">Contactez moi !</a></h2
Reply

#8
that functions impeccably
I have the good file Blush
French citizen (please excuse me for my english Confused )
Having a good knowledge of the PHP but novice with CodeIgniter
I use CodeIgniter 3



Reply

#9
Quote:that functions impeccably
I have the good file

Comme je l'attendais.

My next guess is that you do not have an .htaccess file in place.  (Documentation Here). It will allow you to construct URL's without "index.php" in them.

If you use .htaccess (requires mod_rewrite) the examples first shared should work.
Reply

#10
I have the file .htaccess
Code:
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index.php|resources|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

and the option “rewrite_module” activated in apache
French citizen (please excuse me for my english Confused )
Having a good knowledge of the PHP but novice with CodeIgniter
I use CodeIgniter 3



Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2017 MyBB Group.