第32行语法错误,意外T_PUBLIC

时间:2014-08-22 16:54:41

标签: php

我正在获取此代码的错误。它在第32行的C:\ wamp \ www \ openarc \ application \ controllers \ login.php中出现语法错误,意外的T_PUBLIC。我认为缺少大括号。但无法找到它。请帮助我

<?php

/**
 * This class use to registered users login to the site and logout 
 */
class Login extends CI_Controller{


    /*load the login page*/
    function index($pass_details=false)
    {
        //if user is already logged in restrict login page to user
        if($this->isLoggedin())
        {
            redirect('/');
        }
        //if user is not logged in
        else
        {
            //if login failed pass $pass_details message to login view
            if(isset($pass_details))
            {
                $login_messeage['loginErrorMessage'] = $pass_details;
               // $login_messeage['userName']          = $pass_details['user_name'];
            }
            $login_messeage['page_id'] = "login";
            //pass error message and user_name to view and show login page
            $this->load->view("template",$login_messeage);
        }
    }
    }
    /*take the login form values and do the back end validation and send those values to the Login_model*/
    public function user_login()
    {

        if(!$this->isLoggedin())
        {

            $username = $this->input->post('lg_username');
            $password = $this->input->post('lg_password');
            $url      = $this->input->post('hidden_url');

            //load the login_model 
            $this->load->model('Login_model');

            //create an array and pass username and password
            $user_login_details =array(

                'username' => $username,
                'password' => sha1($password),

            );

            //pass $user_login_details array to the Login_model get_specific_record function 
            $result  = $this->Login_model->get_specific_record($user_login_details);

            //get executed result counter of num_rows into $numrows variable
            $numrows = $result->num_rows();

            //get database values to variable into variables from executed result

            if($numrows>0)
            {
                foreach ($result->result() as $row)
                {
                   $uname        = $row->username;
                   $upassword    = $row->password;
                   $userid       = $row->login_id;
                   $usertype     = $row->user_type;
                   $userrefid    = $row->reference_id;
                }
                if($usertype == 'Ad')
                { //echo "ggg";exit();
                    //check executed result num_rows() counter is grater than 0 

                    //user details set to sessionArray to set session
                    $sessionArray = array(
                         'username'     =>$uname,
                         'userType'     =>$usertype,
                         'refId'        =>$userrefid,
                         'login_status' => true
                    );

                    //create session and redirect user to home page(index page)
                    $this->session->set_userdata($sessionArray);
                    redirect('adminpanel');

                }
                else if ($usertype == 'Op') {
                    //user details set to sessionArray to set session
                    $sessionArray = array(
                         'username'     => $uname,
                         'userType'     => $usertype,
                         'refId'        => $userrefid,
                         'login_status' => true
                    );
                    //create session and redirect user to home page(index page)
                    $this->session->set_userdata($sessionArray);
                    redirect('Production');
                }
                else if($usertype == 'C')
                {

                    //user details set to sessionArray to set session
                    $sessionArray = array(
                         'username'     => $uname,
                         'userid'       => $userid, 
                         'userType'     => $usertype,
                         'refId'        => $userrefid,
                         'login_status' => true
                     );
                    //create session and redirect user to home page(index page)
                    $this->session->set_userdata($sessionArray);
                    $cartSessionArray = array(
                         'user_id'    => $userid, 
                         'status'    => 'A' 
                    );

                    $this->load->model('Cart_model');                           
                    $cart_result  = $this->Cart_model->get_all_cart_data($cartSessionArray);

                    $cart_numrows = $cart_result->num_rows();
                    if($cart_numrows >0)
                    {
                        foreach ($cart_result->result() as $cart_row)
                        {
                            $cart_id = $cart_row->id;
                            $cart_name = $cart_row->name;
                            $cart_price = $cart_row->price;
                            $cart_qty = $cart_row->qty;

                            $insert_cart = array(
                                                'id' => $cart_id,
                                                'name' => $cart_name,
                                                'price' => $cart_price,
                                                'qty' => $cart_qty

                                                 );
                               $res = $this->cart->insert($insert_cart);


                           }

                           if($res)
                           {
                                if ($url == 'index') 
                                {
                                       redirect('place_order');
                                }
                                else 
                                {
                                    redirect($url);
                                }
                              ;//    redirect('/products');
                           }

                            else {

                               if ($url == 'index') 
                                {
                                       redirect('place_order');
                                }
                                else 
                                {
                                    redirect($url);
                                }

                            }
                    }
                    else 
                    {
                         redirect($url);
                    }  
                }
                else if($usertype == 'Ma')
                {

                    //user details set to sessionArray to set session
                    $sessionArray = array(
                         'username'     => $uname,
                         'userid'       => $userid, 
                         'userType'     => $usertype,
                         'refId'        => $userrefid,
                         'login_status' => true
                     );
                    //create session and redirect user to home page(index page)
                    $this->session->set_userdata($sessionArray);
                    redirect('management/monthly_order_count');


                }   

            }
            else
            {
                $pass_details     =  "<div class='alert alert-error'>Username or password is Wrong</div>"; 
                $this->index($pass_details);
            }

        }

        else
        {
            redirect('/');
        }

    }


    /*logout the loged user*/
    public function logout()
    {
        if($this->isLoggedin())
        {
            //unset session data for user logout
            $this->session->sess_destroy();

            //redirect to the home page
            redirect('/');
        }

    }
}

}
?>

2 个答案:

答案 0 :(得分:1)

错字:

    }
}
}  <---this bracket is closing your object

/*take the login form values and do the back end validation and send those values to the Login_model*/
public function user_login()

由于你有一个额外的括号,你的类定义会过早地终止,使public无用,因为它只在类定义中有效。

答案 1 :(得分:1)

您正在关闭第31行的课程定义......

...
28        $this->load->view("template",$login_messeage);
29      } // end if
30    } // end function index
31  } // misplaced end class definition

摆脱31号线。