表单在opencart中提交

时间:2015-11-26 05:55:27

标签: php opencart opencart2.x

我是opencart的新手。我必须为用户编写自定义登录表单。然后我在opencart中设计一个用于登录表单的小代码,如下所示。路径是(MyTheme / temlate / auth / Sign.tpl)

<form action="<?php echo $Sub; ?>" method="GET" enctype="multipart/form-data">
Name:<Input type="text" name="txtUser">
<br>
Password:<input type="password" name="txtPassword"><br>
<input type="submit">   

和控制器就像(Path是controller / auth / Sign.php)

    <?php
    class ControllerAuthSign extends Controller{
        public function index() {
            $data['Sub']=$this->url->link('auth/result','','SSL');

            if(file_exists(DIR_TEMPLATE . $this->config->get('config_template'). '/template/auth/sign.tpl')){
                $this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/auth/sign.tpl',$data));
            }
            else{
                $this->response->setOutput($this->load->view('default/template/account/login.tpl'));
            }
        }
    }
?>

当用户提交表单时必须导航到Result页面(Path is /auth/result.tpl)

    <?php
    echo "Welcome : Mr./Mrs. ".$User;   
?>
<br><p>Your are Loged-In</p>

并且Result的控制器是..(Path是/auth/result.php)

    <?php
    class ControllerAuthResult extends Controller{
        public function index() {
            $data['User']=$_REQUEST['txtUser'];
            $data['Password']=$_REQUEST['txtPassword'];

            if(isset($data)){
                $this->response->redirect($this->url->link('auth/sign', '', 'SSL'))
            }
            $this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/auth/result.tp',$data));
        }
    }
?>

但问题是当我点击提交时,页面导航到

  

http://localhost/opencart/index.php?txtUser=Narayana&txtPassword=narayana

并显示索引页面。任何人都可以帮助如何导航到结果页面......?

先谢谢。

1 个答案:

答案 0 :(得分:1)

使用此

<form action="<?php echo $Sub; ?>" method="POST" enctype="multipart/form-data">
Name:<Input type="text" name="txtUser">
<br>
Password:<input type="password" name="txtPassword"><br>
<input type="submit">