错误403:禁止错误

时间:2013-05-13 09:42:07

标签: codeigniter

我无法使用Codeigniter 2.1中的表单访问控制器。主页有几个链接,我可以访问。但是当我想在表单中提取数据时,我会显示403禁止错误:

禁止您无权访问此服务器上的/Pruebas/application/controllers/valiar.php。

观点:

<!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>

控制器:

<?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");
         }  
} 

我的.htacess文件中包含deny from all。我怎样才能进入控制器?

感谢。

1 个答案:

答案 0 :(得分:2)

您的表单操作应如下所示:

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

...而不是:

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

您无法将控制器的文件路径作为表单操作的位置。