使用成功消息在magento中重定向页面

Mel*_*vin 3 redirect module magento

我正在开发一个自定义模块,我在其中输入值,如果它在db中匹配,它会重定向到主页,并在主页上显示为blah Blah,或者如果没有进入登录页面.我尝试了以下公共函数,条件为

if(count($alldata)==1) {
Mage::getSingleton('helloworld/helloworld')->addSuccess('my message goes here');

$this->_redirect('home');


 }else {
$this->_redirect('customer/account');
  }
Run Code Online (Sandbox Code Playgroud)

但这会给出一个预先请求错误.

在此输入图像描述

这是我在控制器中添加的全部代码

 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');
  }

  }
  }
Run Code Online (Sandbox Code Playgroud)

这不是正确的格式吗?还是有更多我应该做的改变?

更新的代码

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');
  }

  }
  }
Run Code Online (Sandbox Code Playgroud)

Qai*_*tti 7

使用Magento全局消息传递系统:

成功

Mage::getSingleton('core/session')->addSuccess('my message goes here');
Run Code Online (Sandbox Code Playgroud)

错误

Mage::getSingleton('core/session')->addError('my message goes here');
Run Code Online (Sandbox Code Playgroud)

警告

Mage::getSingleton('adminhtml/session')->addWarning('my message goes here');
Run Code Online (Sandbox Code Playgroud)

如果您的模板支持,该消息将显示在下一个呈现的页面中.

重定向或重新加载用户以显示消息.