axmug
axmug

Reputation: 466

Error 403: forbidden error

I can't access a controller using a form in Codeigniter 2.1. The homepage has several links and I can access. But when I want to submint data in a form I display the 403 forbidden error:

Forbidden you don't have permission to access /Pruebas/application/controllers/valiar.php on this server.

The view:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Anuncios</title>
<link rel="stylesheet" href="/Pruebas/css/estilos.css" type="text/css"   
    media="screen"/>    
<link rel="stylesheet" href="/Pruebas/css/logestilos.css" type="text/css" 
    media="screen"/>
</head>

<body>

<div id="contenedor">
<div id="menu">
    <label for="home" id="inicio"><a href="http://localhost/Pruebas/index.php 
            /cindice/">Inicio</a></label> 
    <label for="acceso" id="login"><a href="http://localhost/Pruebas/index.php
            /cindice/publicar">Publicar anuncio</a></label> 
    <label for="reg" id="registro"><a href="http://localhost/Pruebas/index.php
            /cindice/registro">Registro</a></label>
    <label for="empresa" id="sobrempresa"><a href="http://localhost/Pruebas
            /index.php/cindice/sobempresa">Sobre nosotros</a></label>
    <label for="contacto" id="contactar"><a href="http://localhost/Pruebas   
            /index.php/cindice/contacto">Cont&aacute;ctanos</a></label>
</div>  
</div>

<div id="acformulario"> 
    <?php echo validation_errors(); ?>
    <form action="http://localhost/Pruebas/application/controllers   
            /validar.php" method="post">
    <label for="correo" id="dcorreo">Direcci&oacute;n de correo</label>
    <input type="text" name="drcorreo" id="dcc"/><br /><br />
    <label for="contrasenya" id="cont">Contrase&ntilde;a</label>
    <input type="password" name="contrasena" id="cmcont"/><br /><br />

    <input type="submit" name="envia" id="bentrar" value="Entrar" />    
    </form>
 </div> 

</body>
</html>

The controller:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

  class Cindice extends CI_Controller {

function __construct() {
    parent::__construct();
}

public function index()
{
    $this->load->view('indice');
}

    public function validar() 
{
    $this->input->post('drcorreo');
    $this->input->post('contrasena');

    $this->form_validation->set_rules('correo','Direcci&oacute;n de  
            correo','trim|required|valid_email|xss_clean');

            $this->form_validation->set_rules('contrasenya','Contrase&ntilde;a',
            'trim|required|md5|xss_clean');

    if ($this->form_validation->run())
     {
        echo ("validaci&oacute;n v&aacute;lida");   
     }
    else {
        $this->load->view('');
        echo ("validaci&oacute;n incorrecta");
         }  
} 

My .htacess file has the words deny from all. How can I acess to the controller?

Thanks.

Upvotes: 0

Views: 2641

Answers (1)

Mudshark
Mudshark

Reputation: 3253

Your form action should look like this:

<?php echo form_open('validar'); // needs the form helper to be loaded ?>

... instead of:

<form action="http://localhost/Pruebas/application/controllers/validar.php" method="post">

You can't give the controller's file path as the location for the form action.

Upvotes: 2

Related Questions