So lets get started.
First create a table in your database by executing the following sql query.
CREATE TABLE ‘users’ (
‘id’ int(11) NOT NULL auto_increment,
‘firstname’ varchar(100) default NULL,
‘lastname’ varchar(100) default NULL,
‘email’ varchar(255) NOT NULL,
‘username’ varchar(100) NOT NULL,
‘password’ varchar(15) NULL,
PRIMARY KEY (’id’)
)
Next create a model against this table in your application/model/ directory. I am creating Users.php and writing the following code in it.
<?
class Users extends Zend_Db_Table
{
protected $_name=”users”;
}
?>
Now create a controller named AuthController.php in application/controllers/ directory and place the following code in it
class AuthController extends Zend_Controller_Action
{
public function loginAction()
{
}
public function signupAction()
{
}
public function logoutAction()
{
}
public function homeAction()
{
}
}
As we have now create our controller and three actions, we will need to create templates files for actions. Go application/views/scripts and create a folder named “auth” and create three files in application/views/scripts/auth named
login.phtml
signup.phtml
logout.phtml
home.phtml
As we will need to have forms for sign up and login so we are going to create to files named “LoginForm.php” and “RegistrationForm.php” for these forms in application/forms/ directory.
In LoginForm.php place the following code
class LoginForm extends Zend_Form
{
public function init()
{
}
}
class LoginForm extends Zend_Form
{
public function init()
{
}
}
and in the RegistrationForm.php place the following code
class RegistrationForm extends Zend_Form
{
public function init()
{
}
}
So far you can see that we have created all our necessary files.
No lets put the application logic in these files.
We are starting from the forms first.
In LoginForm.php, write the following code
class LoginForm extends Zend_Form
{
public function init()
{
$username = $this->createElement(’text’,'username’);
$username->setLabel(’Username: *’)
->setRequired(true);
$password = $this->createElement(’password’,'password’);
$password->setLabel(’Password: *’)
->setRequired(true);
$signin = $this->createElement(’submit’,’signin’);
$signin->setLabel(’Sign in’)
->setIgnore(true);
$this->addElements(array(
$username,
$password,
$signin,
));
}
}
In the above form we are creating two text elements named “usernam” and “password”, set their labels and setRequred to true. Next we create a submit button.
Similarly in RegistrationForm.php, write the following code
class RegistrationForm extends Zend_Form
{
public function init()
{
$firstname = $this->createElement('text','firstname');
$firstname->setLabel('First Name:')
->setRequired(false);
$lastname = $this->createElement('text','lastname');
$lastname->setLabel('Last Name:')
->setRequired(false);
$email = $this->createElement('text','email');
$email->setLabel('Email: *')
->setRequired(false);
$username = $this->createElement('text','username');
$username->setLabel('Username: *')
->setRequired(true);
$password = $this->createElement('password','password');
$password->setLabel('Password: *')
->setRequired(true);
$confirmPassword = $this->createElement('password','confirmPassword');
$confirmPassword->setLabel('Confirm Password: *')
->setRequired(true);
$register = $this->createElement('submit','register');
$register->setLabel('Sign up')
->setIgnore(true);
$this->addElements(array(
$firstname,
$lastname,
$email,
$username,
$password,
$confirmPassword,
$register
));
}
}
In the above code we have created several elements and place them in the form. Keep in mind that we have place * next to compulsory elements labels.
As we have now created our forms, next step is to display these in the templates files. However to do this we will first need to initialize these in our controller
So in AuthController.php, write the following code
class AuthController extends Zend_Controller_Action
{
public function homeAction()
{
$storage = new Zend_Auth_Storage_Session();
$data = $storage->read();
if(!$data){
$this->_redirect('auth/login');
}
$this->view->username = $data->username;
}
public function loginAction()
{
$users = new Users();
$form = new LoginForm();
$this->view->form = $form;
if($this->getRequest()->isPost()){
if($form->isValid($_POST)){
$data = $form->getValues();
$auth = Zend_Auth::getInstance();
$authAdapter = new Zend_Auth_Adapter_DbTable($users->getAdapter(),'users');
$authAdapter->setIdentityColumn('username')
->setCredentialColumn('password');
$authAdapter->setIdentity($data['username'])
->setCredential($data['password']);
$result = $auth->authenticate($authAdapter);
if($result->isValid()){
$storage = new Zend_Auth_Storage_Session();
$storage->write($authAdapter->getResultRowObject());
$this->_redirect('auth/home');
} else {
$this->view->errorMessage = "Invalid username or password. Please try again.";
}
}
}
}
public function signupAction()
{
$users = new Users();
$form = new RegistrationForm();
$this->view->form=$form;
if($this->getRequest()->isPost()){
if($form->isValid($_POST)){
$data = $form->getValues();
if($data['password'] != $data['confirmPassword']){
$this->view->errorMessage = "Password and confirm password don't match.";
return;
}
if($users->checkUnique($data['username'])){
$this->view->errorMessage = "Name already taken. Please choose another one.";
return;
}
unset($data['confirmPassword']);
$users->insert($data);
$this->_redirect('auth/login');
}
}
}
public function logoutAction()
{
$storage = new Zend_Auth_Storage_Session();
$storage->clear();
$this->_redirect('auth/login');
}
}
It will be hard for beginners to understand the above code. So lets break it and see what this code is all about.
public function homeAction()
{
$storage = new Zend_Auth_Storage_Session();
$data = $storage->read();
if(!$data){
$this->_redirect('auth/login');
}
$this->view->username = $data->username;
}
The above code is very simple. We first create instance of Zend_Auth_Storage_Session class. Next we call its read method. This will return a row of records if the users is authenticated, otherwise null.
We check if the data is null. If yes, we redirect our page to the login action.
If data is found, it means that user is authenticated and we assign username to the view template. So display welcome message in our home.phtml template, open views/scripts/auth/home.phtml and write the following code.
Welcome <?=$this->username?>,<br>
This is your home page<br>
<a href=”<?=$this->url(array(’controller’=>’auth’,'action’=>’logout’))?>”>click here to logout</a>
In the code above we have a link to the logout action, which simply destroy our session.
Next
public function loginAction()
{
$users = new Users();
$form = new LoginForm();
$this->view->form = $form;
if($this->getRequest()->isPost()){
if($form->isValid($_POST)){
$data = $form->getValues();
$auth = Zend_Auth::getInstance();
$authAdapter = new Zend_Auth_Adapter_DbTable($users->getAdapter(),'users');
$authAdapter->setIdentityColumn('username')
->setCredentialColumn('password');
$authAdapter->setIdentity($data['username'])
->setCredential($data['password']);
$result = $auth->authenticate($authAdapter);
if($result->isValid()){
$storage = new Zend_Auth_Storage_Session();
$storage->write($authAdapter->getResultRowObject());
$this->_redirect('auth/home');
} else {
$this->view->errorMessage = "Invalid username or password. Please try again.";
}
}
}
}
In the fist two lines we create instances of our model and login form with statements
$users = new Users();
$form = new LoginForm();
In the third line we assign form instance to view template for display purpose.
The logic of logging in is defined in the next lines
We first check that the users has posted the request. If yes we check that he has submitted valid form. If both the condition return true, we get the values submitted as
$data = $form->getValues();
Next we create instance of Zend_Auth with code
$auth = Zend_Auth::getInstance();
and $authAdapter with
$authAdapter = new Zend_Auth_Adapter_DbTable($users->getAdapter(),’users’);
To perform authentication we will need to either use existing Adapters provided by Zend or create our own.
Here I am using DbTable Adapter provided by Zend, giving adapter and database table name. our table name is users.
Next we set identity and credential columns.
After that we give posted values to the $adapter.
To perform authentication we will need to call Zend_Auth authenticate() method, for this we write
$result = $auth->authenticate($authAdapter);
Next we check if the result is valid with statement $result->isValid(). This either return true or false. If it return true it means that we found a record in the database.
If valid record is found we create session instance and store the user data in the session with statements
$storage = new Zend_Auth_Storage_Session();
$storage->write($authAdapter->getResultRowObject());
and redirect our request to home action.
$this->_redirect(’auth/home’);
If result is not valid we assign error message to our template file
In application/views/scripts/login.phml, write the following
<?
if(isset($this->errorMessage)){
echo $this->errorMessage;
}?>
<?
echo $this->form;
?>
<a href=”<?=$this->url(array(’controller’=>’auth’,'action’=>’signup’))?>”>New users click here?</a>
In the code above we first check the error message, if set we display it.
In the next line we display our login form.
Next
public function signupAction()
{
$users = new Users();
$form = new RegistrationForm();
$this->view->form=$form;
if($this->getRequest()->isPost()){
if($form->isValid($_POST)){
$data = $form->getValues();
if($data['password'] != $data['confirmPassword']){
$this->view->errorMessage = "Password and confirm password don't match.";
return;
}
if($users->checkUnique($data['username'])){
$this->view->errorMessage = "Name already taken. Please choose another one.";
return;
}
unset($data['confirmPassword']);
$users->insert($data);
$this->_redirect('auth/login');
}
}
}
This action is used for signup purpose. We create instance of our model class and Registration Form. And assign form to our view template.
Check for the post request and valid form.
If the form is valid we get form values. Check if both the password fields don’t have same data. If they are not same we assign error message to the view template.
Next we call our checkUnique() method of the model class. This checkUnique() method check the data in the database. If row with the posted username is already in the database it return ture, means username already exist in the database. If username found we assign error message to view telling the user to choose another username. It not we insert the data in the database. And redirect the request to login action.
Our model class look as
class Users extends Zend_Db_Table
{
protected $_name="users";
function checkUnique($username)
{
$select = $this->_db->select()
->from($this->_name,array('username'))
->where('username=?',$username);
$result = $this->getAdapter()->fetchOne($select);
if($result){
return true;
}
return false;
}
}
To create a template file for the signup action, place the following code in views/scripts/auth/signup.phtml
<?
if(isset($this->errorMessage)){
echo $this->errorMessage;
}?>
<h4>Sign up</h4>
<?
echo $this->form;
?>
first we check for the error, if error message is set in the action we display that.
Next we display our Registarion form.
The last and final thing is our logout action.
public function logoutAction()
{
$storage = new Zend_Auth_Storage_Session();
$storage->clear();
$this->_redirect('auth/login');
}
Here we create instance of Zend_Auth_Storage_Session and clear it.
And we then redirect our request to login action.
Hello, thanks for the tutorial, but I get a Fatal error: Class ‘Users’ not found in /var/www/app/application/controllers/AuthController.php on line 16. What must i do? Thanks.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteWell hex.
ReplyDeleteIt seems that you haven't include path to your models in your bootstrap file.
you need to write,
set_include_path('path/to/models'.get_include_path());
I usually do it like
set_include_path('.'
. PATH_SEPARATOR . ROOT_DIR . '/application'
. PATH_SEPARATOR . ROOT_DIR . '/application/models'
. PATH_SEPARATOR . get_include_path()
);
thanks, you were right, i wasn't using the autoloader right. But now, when i try to click, new user, register here link i get... Fatal error: Call to a member function getAdapter() on a non-object
ReplyDeleteIt seems that you haven't configured your database correctly in your bootstrap file.
ReplyDeletedid you ever make this thing work?
ReplyDeletei just cant get this to work
ReplyDeletealways get
Warning: include(LoginForm.php) [function.include]: failed to open stream: No such file or directory in C:\Archivos de programa\Zend\ZendServer\share\ZendFramework\library\Zend\Loader.php on line 83
Warning: include() [function.include]: Failed opening 'LoginForm.php' for inclusion (include_path='C:\Archivos de programa\Zend\Apache2\htdocs\integra2;.;C:\Archivos de programa\Zend\ZendServer\share\ZendFramework\library') in C:\Archivos de programa\Zend\ZendServer\share\ZendFramework\library\Zend\Loader.php on line 83
Fatal error: Class 'LoginForm' not found in C:\Archivos de programa\Zend\Apache2\htdocs\integra2\application\default\controllers\AuthController.php on line 28
FIXED:
ReplyDeletewith
set_include_path(INTEGRA_PATH_ROOT. "\\application\\default\\models" . PATH_SEPARATOR . INTEGRA_PATH_ROOT. "\\application\\forms" . PATH_SEPARATOR . INTEGRA_PATH_ROOT . PATH_SEPARATOR . get_include_path());
this instruction fix the LoginForm and Users "not found " problem, hope itll help someone
Hi,, thanks for this tutorial it really works so cool and able to learn many things
ReplyDeleteThank you so much for the very clear and explainatory tutorial.. Great job
ReplyDeleteIn stead of all set_include_paths, you can also let your model class start with Default_Model_, so in this case Default_Model_Users. Then it will be automatically included
ReplyDeleteThis comment has been removed by the author.
ReplyDeletehi this is my index.php file
ReplyDeleteerror_reporting(E_ALL|E_STRICT);
date_default_timezone_set('Europe/London');
set_include_path('.' . PATH_SEPARATOR . './library/'
. PATH_SEPARATOR . './application/models/'
. PATH_SEPARATOR . './application/lib/'
. PATH_SEPARATOR . get_include_path());
include "Zend/Loader.php";
Zend_Loader::loadClass('Zend_Controller_Front');
Zend_Loader::loadClass('Zend_Registry');
Zend_Loader::loadClass('Zend_View');
Zend_Loader::loadClass('Zend_Config_Ini');
Zend_Loader::loadClass('Zend_Db');
Zend_Loader::loadClass('Zend_Db_Table');
Zend_Loader::loadClass('Zend_Debug');
Zend_Loader::loadClass('Zend_Auth');
// load configuration
$config = new Zend_Config_Ini('./application/config.ini', 'general');
Zend_Registry::set('config', $config);
// setup database
$db = Zend_Db::factory($config->db->adapter,
$config->db->config->toArray());
Zend_Db_Table::setDefaultAdapter($db);
Zend_Registry::set('db', $db);
// setup controller
$frontController = Zend_Controller_Front::getInstance();
$frontController->throwExceptions(true);
$frontController->setControllerDirectory('./application/controllers');
// run!
$frontController->dispatch();
but its throwing error like
The requested URL /zendauth/auth/login was not found on this server. Apache/2.2.11 (Ubuntu) PHP/5.2.6-3ubuntu4.2 with Suhosin-Patch Server at localhost Port 80
what is the problem please help me out thank you...have a nice day
Thanks for this great post. I'm not understanding where in this code you put your database configuration (mysql: username, password, dbname, table name)
ReplyDeletehi thanks for ur reply i have my db in the config.ini
ReplyDeleteHello sir,do this function important in sign up and login authentification form : public function preDispatch()
ReplyDeletehell sir i need 2 know what code i have to write in bootstrap.php and index.php pls help me give me a small example... thank u
ReplyDeletePlease help me out regarding application/Bootsrap.php and index.php.pls give sample file..
ReplyDeleteOk mate, but what if i want to hash my password (when registering a new user) with md5? How can i do that?
ReplyDeletepublic function checkcpwd($id,$opassword)
ReplyDelete{
$id = (int)$id;
$data = array('member_id'=>$id, 'password'=>$opassword);
$row = $this->fetchRow($data,'member_id='.(int)$id , 'password='.$opassword );
}
***********
iam calling this function to fetch the row from the database where the table contains the given id and password.......
its not working plz help me
hi,I m new to Zend and i have followed all the steps but need to know the url type on browser to get it going.put code in location c:/xampp/htdocs/zend-login directory
ReplyDeletebut when i type url http://localhost/zend-login/public then it redirects to zend frame work page defines in index.phtml in views/script/index directory.
NOT Working
Deletehi , i can't display my Login form, here's what i get:
ReplyDeleteerrorMessage)){ echo $this->errorMessage; } ?> form ;?> New users click here?
how did you fix the prob..pls tel me
Deletethe above problem has been solved, now got one more isue with , the login and log out action, can some one guide me, both actionbs dont work
ReplyDeleteLB
Thanks you very much it works like a charm
ReplyDeletethis is the best
not really like a charm i took me ssome time to figure out that it missing some functions like checkUnike in in classe users, and need to a add a column in myDB for confirmpassword, otherwise it will no redirect.
ReplyDeleteLB
It works ok, is this possible to use a front controller plugin to use it in a Modular Directory Structure thanks
ReplyDeleteokz.....
ReplyDeleteSimple and clear...
ReplyDeleteI've searched a lot for a tutorial like this.
Good work! thanks ;)
Easy For Understand
ReplyDeleteHmmm...somehow Welcome username?>, doesn't work. It outputs everything else perfectly, even the logout link, but I can't get the username...any suggestions?
ReplyDeleteThanks a lot for this awesome tutorial!
it is nice for begginers simple to understand but i didnt get the output .......
ReplyDeletehttp://localhost/ZendProjects/new_zanayat.com/public/auth/signup
ReplyDeletegives me ..
Not Found
The requested URL /ZendProjects/new_zanayat.com/public/auth/signup was not found on this server.
Thanks for the great tutorial...
ReplyDeleteA great tutorial! It works!
ReplyDeleteI just hat to configure the classname of the DB-file (Users.php) and the classname of the forms.
They have to be like the path where they are to find
Thank you !
thanks for the tutorial, I get a Fatal error: Class 'Users' not found in /home/trainee/manish_verma/ZF/helloWorld/application/controllers/UserController.php on line 27,.help me...
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteHi,
ReplyDeletefinally i got everything working . only problem was with the autoloader configurations and the include path settings .
add these to application.ini
resources.db.adapter = PDO_MYSQL
resources.db.params.host = localhost
resources.db.params.username = root
resources.db.params.password =
resources.db.params.dbname = db
include path and auto load configuration
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
realpath(APPLICATION_PATH . '/models'),
realpath(APPLICATION_PATH . '/forms'),
get_include_path(),
)));
include "Zend/Loader/AutoLoader.php";
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->setFallbackAutoloader(true);
also there is a problem in the LoginForm.php
need to change addElement to addElements
yes its nice tutorial but the problem is that ...there is no clear cut help for creating database and how to deal boot strap file ...as we are beginners so confused about it..........if u include it ,it will be great ..........remaining work is great
ReplyDeleteHi I have copied the above code in my application but when i try to run the code with the url : "http://localhost/ZendRegister/quickstart/public/auth/", it gives me an error stating 'Page not found'. But when i run through "http://localhost/ZendRegister/quickstart/public/auth/login", it gives me a blank page. Plz help me, where m i wrong.
ReplyDeleteI have a suggestion to the the author.. Please remove the program you have written above..The tutorial is helpful for beginners but there are errors on the program.
ReplyDeleteSo... beginners.. don't copy paste .. it will make errors....
Hi thanks for tutorial, everything is ok except my DB structure, I believe thah this is rarely.
ReplyDeleteAny way thanks
its very helpful for the beginner ,
ReplyDeletei want to display login form on all my pages that use different controllers. I need to repeat this code in all controllers?
ReplyDeleteCouldn't get it working right off but here's what I changed to make it work using application.ini and very minimal index and bootstrap.
ReplyDeleteWarning - if you are copy/pasting code make sure you change the single quotes and double quotes as they show up in my editor as the wrong kind of characters and do throw a php error if not caught.
My main problem was - I was getting error on the Users() class and LoginForm() class and RegistrationForm() class - saying class Users not found (same for the forms). So I changed the class name by prepending Application_Model_DbTable_ to Users for the dbtable class. Also I saved that under application/models/dbtable folder.
For the Forms, I did pretty much the same by changing the class name by prepending Application_Form_ to LoginForm and put the forms in application/forms folder.
Then you have to change the AuthController.php to match those new names so $users= new Application_Model_DbTable_Users(). Same for the forms.
Make sure you either use the exact same table name and table fields for your Users table, otherwise you have to make changes to the forms and the dbtable class so I would suggest for beginners they stick to exactly the table as in this example.
BTW I already had my db resource defined in the application.ini so didn't have to do that.
Why create logout.phtml if it's never used?
ReplyDeleteI am getting
ReplyDeleteFatal error: Class 'Users' not found in C:\xampp\htdocs\vip\application\controllers\AuthController.php on line 17
below is my code.
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH',
realpath(dirname(__FILE__) . '/../application'));
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV',
(getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV')
: 'production'));
// Typically, you will also want to add your library/ directory
// to the include_path, particularly if it contains your ZF installed
set_include_path(implode(PATH_SEPARATOR, array(
dirname(dirname(__FILE__)) . '/library',
get_include_path(),
)));
set_include_path(APPLICATION_PATH. "\\models" . PATH_SEPARATOR . APPLICATION_PATH. "\\forms" . PATH_SEPARATOR . APPLICATION_PATH . PATH_SEPARATOR . get_include_path());
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
Can anyone please help me?
At last I found the solution.
ReplyDeleteClass name should be like Application_Model_Users instead of Users. I think I am using different version of Zend.
So instead of this below line
class Users extends Zend_Db_Table
use
class Application_Model_Users extends Zend_Db_Table
This is a better Check Unique function that works with Zend Application and PDO MySQL.
ReplyDeletepublic function checkUnique($username)
{
$select = $this->_dbTable->select()
->from($this->_name,array('username'))
->where('username=?',$username);
$stmt = $select->query();
$result = $stmt->fetchAll();
if($result){
return true;
}
return false;
}
Really appreciate your work! Nice Tutorial Dude!
ReplyDeletehi
ReplyDeletefine blog it is very help full
thanks
hello friend i need help in cookie of zend framework plz suggest me a url which help me
ReplyDeleteThanks for your application post, but you didn't included bootstrap file. It will be a problem to beginners like me.
ReplyDeleteIn my application bootstrap file i didn't included any script not yet, i am running applications with the help of indexAction. so what code i have to add in bootstrap file to run the above application like you.
i am getting this error: "Invalid username or password", however i am entering correct username and password. anybody please help!!
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteHi I have copied the above code in my application but when i try to run the code with the url : "http://localhost/myproject/public/auth/", it gives me an error stating 'Page not found'. But when i run through "http://localhost/myproject/public/auth/login", it gives me a blank page. Plz help me, where m i wrong.
ReplyDeleteBut you did a great job for beginners.
Thanks.
I am getting following error.
ReplyDeleteFatal error: Class 'LoginForm' not found in D:\wamp\www\zend_registration\application\controllers\AuthController.php on line 19
below is my code.
error_reporting(E_ALL|E_STRICT);
//ini_set('display_errors',1); // set this to 0 on live version
//http://zendgeek.blogspot.in/2009/07/zend-framework-sign-up-and.html
// Define path to application directory
defined('APPLICATION_PATH')|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
/*set_include_path('.' . PATH_SEPARATOR . '../library'.
PATH_SEPARATOR . '../application/models'.
PATH_SEPARATOR . '../application/forms'.
PATH_SEPARATOR . get_include_path());
*/
set_include_path(PATH_SEPARATOR. "\\application\\models" .
PATH_SEPARATOR . "\\application\\forms" .
PATH_SEPARATOR . get_include_path());
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap()
->run();
Can anyone please help me?
Thanks.
Hi..
ReplyDeleteI also got an error like this..Fatal error: Class 'Users' not found in C:\webserver\htdocs\server_temp\application\controllers\AuthController.php on line 21.. I tried all the suggested solution above, but the error remains..Please help..
Thanks for the tutorial :)
ReplyDeleteHi, I have done all the steps very carefully also correct all the single quote and double quote.But How I will run this auth I am unable to understand.Please suggest me.
ReplyDeleteIt worked! With some adjustments: I replaced the Users in the AuthController with: Application_Model_Users();
ReplyDeleteHope this helps...
hi....
ReplyDeletei follow all procedure....
but when i run this on browser....
the screen is blank...and no error or login form is shown....
please help me...
Hello
ReplyDeleteadd these to application.ini
resources.db.adapter = PDO_MYSQL
resources.db.params.host = localhost
resources.db.params.username = root
resources.db.params.password =
resources.db.params.dbname = db
and add path in index.php(in public or webroot folder)
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
realpath(APPLICATION_PATH . '/models'),
realpath(APPLICATION_PATH . '/forms'),
get_include_path(),
)));
add these lines in AuthController
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->setFallbackAutoloader(true);
and please remove all graphical char in all files like ‘ to ' and ” to "
ok your app will work fine
Thanks
Piyush
Hi,
ReplyDeleteI have download a trial version zend server and i have created a project from command prompt cmd->run->zf create project user and i have put all contents as per your suggestion but it is showing me a zend server test page so kindly help me.
hello icant redirect after login to home page..
ReplyDeleteshows The requested URL /project/index/home was not found on this server.
can anyone help ?
In my case this url(default) gives output http://localhost/zend_auth/
ReplyDeleteBut
When I try to access any other url like http://localhost/zend_auth/auth/login
or
http://localhost/zend_auth/index/add
It gives me error "The requested URL /zend_auth/index/add was not found on this server."
Please help me to resolve it.
Hello There ,
ReplyDeleteI can't display my Login form, here's what I am getting:
errorMessage)){ echo $this->errorMessage; } ?> form ;?> New users click here?
can you solution for this to solve this issue .
Thanks in advance
Thanks for nothing. This piece of shit tutorial does not work.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteI am getting following error.
ReplyDeleteFatal error: Class 'ZendSkeletonModule\Zend_Db_Table' not found in /var/www/html/zf2-tutorial/ZendSkeletonApplication/module/regist/Module.php on line 18