I am working on a custom module where i enter values and if it matches in db it redirects to home page with a message that displays on home page as blah Blah ,or if not goes to login page. I tried the below public function with the condition as
if(count($alldata)==1) {
Mage::getSingleton('helloworld/helloworld')->addSuccess('my message goes here');
$this->_redirect('home');
}else {
$this->_redirect('customer/account');
}
but this gives a precces request error.
this is my whole code i added in my controller
public function loginnAction()
{
if($this->getRequest()->getParams()) {
$param = $this->getRequest()->getParams();
$username = $param['fname'];
$mobile = $param['mobileno'];
$connectionresource = Mage::getSingleton('core/resource');
$readconnection = $connectionresource->getConnection('core_read');
$table = $connectionresource->getTableName('helloworld/helloworld');
$allrecord = $readconnection->select()->from(array('helloworld'=>$table))->where('helloworld.mobileno=?', $mobile)
->where('helloworld.firstname=?', $username);
$alldata =$readconnection->fetchAll($allrecord);
if(count($alldata)==1) {
Mage::getSingleton('helloworld/helloworld')->addSuccess('my message goes here');
$this->_redirect('home');
}else {
$this->_redirect('customer/account');
}
}
}
Is it not the correct format ?Or is there more i should do change?
Updated code
public function loginnAction()
{
if($this->getRequest()->getParams()) {
$param = $this->getRequest()->getParams();
$username = $param['fname'];
$mobile = $param['mobileno'];
$connectionresource = Mage::getSingleton('core/resource');
$readconnection = $connectionresource->getConnection('core_read');
$table = $connectionresource->getTableName('helloworld/helloworld');
$allrecord = $readconnection->select()->from(array('helloworld'=>$table))->where('helloworld.mobileno=?', $mobile)
->where('helloworld.firstname=?', $username);
$alldata =$readconnection->fetchAll($allrecord);
if(count($alldata)==1) {
Mage::getSingleton('core/session')->addSuccess('my message goes here');
$this->_redirect('home');
}else {
$this->_redirect('customer/account');
}
}
}