0
我無法使用Codeigniter 2.1中的窗體訪問控制器。該主頁有幾個鏈接,我可以訪問。但是當我想要以某種形式提取數據時,我會顯示403禁止的錯誤:錯誤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á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ón de correo</label>
<input type="text" name="drcorreo" id="dcc"/><br /><br />
<label for="contrasenya" id="cont">Contraseñ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ón de
correo','trim|required|valid_email|xss_clean');
$this->form_validation->set_rules('contrasenya','Contraseña',
'trim|required|md5|xss_clean');
if ($this->form_validation->run())
{
echo ("validación válida");
}
else {
$this->load->view('');
echo ("validación incorrecta");
}
}
我.htacess文件有句話從所有拒絕。我怎樣才能訪問控制器?
謝謝。
<?php echo form_open('cindice/validar') - 爲了安全起見。 – 2013-05-13 09:51:36
他的代碼有點不清楚。他似乎有一個'validar.php'控制器,但是他也有一個控制器'cindice.php'和'validar'方法。這取決於他的設置 - 但是,好,趕上:) – Mudshark 2013-05-13 09:56:49
正確...但根據上面提供的代碼摘錄,表單應該提交給cindice/validar。我認爲他對CI很陌生,並濫用MVC模式。 – 2013-05-13 10:31:02