Я разрабатываю простое приложение, но оно выдает сообщение об ошибке.
Класс контроллера:
<?php class RegisterController extends AppController { public $helpers=array('Html','Form','Session'); public $components=array('Session'); public function index(){ } public function register() { echo "inside fun index inside controller usersform, this function adds data to the database taking values from the registration form\n"; if( !empty($this->request->data )) { //pr($this->request->data);exit; $username=$this->request->data['username']; $password=$this->request->data['password']; $email=$this->request->data['email']; $first_name=$this->request->data['first_name']; $last_name=$this->request->data['last_name']; $savedData=array(); $savedData['usersform']=array( 'username'=>$username, 'password'=>$password, 'email'=>$email, 'first_name'=>$first_name, 'last_name'=>$last_name ); if($this->usersform->save($savedData)) { //echo "/ndata is saved in the database"; $this->Session->setFlash("data is now saved in database, you can now login to your account"); $this->redirect(array('action'=>'login')); } else { $this->Session->setFlash("Unable to save data"); } } } public function login() { echo "inside func login inside controller usersform, this func would check name an password that the usersform has filled and match it against database records"; if(!empty($this->request->data)){ $username=$this->request->data['username']; $password=$this->request->data['password']; $searchData=$this->Teacher->find('first',array('conditions'=>array('username'=>$username, 'password'=>$password))); //echo '<pre>'; //pr($searchData);exit; if(empty($searchData)) { //$message = 'Not Found'; $this->Session->setFlash("could not find data matching ur login details"); } else { //$message = 'Login Successfully'; $this->Session->write('username',$username); $this->Session->setFlash("congrats, you have successfully logged in"); $this->redirect(array('controller'=> 'usersform', 'action'=>'welcome')); } } } public function welcome() { echo "inside the welcome func inside teachers controller"; echo $this->Session->read('username'); // $this->Session->setFlash("welcome to your account" .$username); } } ?>
Модельный класс:
<?php class usersform extends AppModel { } ?>
Класс просмотра:
<form action="<?php echo $this->html->url(array('controller'=>'Teachers', 'action'=>'index')); ?>" method="POST"> Username:<input type="text" name="username" size="30"> password:<input type="password" name="password" size="30"> email:<input type="text" name="email" size="10"> First_Name:<input type="text" name="First_Name" size="30"> Last_Name:<input type="text" name="Last_Name" size="30"> <input type="submit" name="submit" size="15"> </form>
Он выдает сообщение об ошибке следующим образом:
Ошибка отсутствия видимости: вид AppController :: index () не найден. Ошибка: подтвердите, что вы создали файл: D: \ xampp \ htdocs \ project \ UserRegisterForm \ app \ View \ App \ index.ctp