-1

这可能是我关于身份验证的第二个问题。但我仍然无法验证我的登录表单..因此我决定再次发布我的代码。那么谁能告诉我身份验证是如何完成的????

//this is my index page, where a user logs in
<div align="center">
<h2> ONLINE LIBRARY SYSTEM </h2>
<h4> If you have already registered into our library system . Please Login below </h4?
<br />
</div>
<div class="form">
<fieldset>
<?php
echo $this->Form->create('Member');
echo $this->Form->input('username');
echo $this->Form->input('password');
echo $this->Form->end('Login');
?>
<h4> If not registerd. Register here <?php echo $this->Html->link('Register     Now',array('controller'=>'members','action'=>'register')); ?> </h4>
</fieldset>
</div>

我需要在我的索引函数中提到什么?

function index()
{

}

我必须在哪里编写/调用 Auth 组件......???谁能给我解释一下……请不要张贴食谱的链接……我读了将近 4 次,并没有完全理解

4

1 回答 1

1

当用户调用控制器时,通常会调用 index 函数,而无需指定操作。例如:http://localhost/cake/<some-controller>

. 因此,进入 index() 函数的内容取决于您想要显示的内容,如果用户没有指定特定操作,例如http://localhost/cake/<some-controller>/<some-action>(例如http://localhost/cake/library/show_book

作为一种实践,大多数开发人员将上述代码(登录内容)放入login()函数中。

以下是一些附加信息,您可以阅读这些信息,以使身份验证正常工作:

  • 添加“Auth”作为组件之一;
  • 在 AppController 中修改 beforeFilter
  • 如果任何操作应该绕过身份验证方案,请在每个控制器中修改 beforeFilter。
于 2013-01-24T12:52:46.643 回答