codeigniter配置文件页面编辑

时间:2018-06-24 19:17:27

标签: php codeigniter session edit

我要为我的项目编辑配置文件页面。我尝试了一些个人资料页面。但是我犯了一个错误。

如何创建个人资料页面?错误是:

An uncaught Exception was encountered
Type: ArgumentCountError

Message: Too few arguments to function CProfile_edit::update(), 0 passed in C:\xampp\htdocs\erp\system\core\CodeIgniter.php on line 532 and exactly 1 expected

Filename: C:\xampp\htdocs\erp\application\controllers\CProfile_edit.php

Line Number: 14

Backtrace:

File: C:\xampp\htdocs\erp\index.php
Line: 315
Function: require_once

我总是给它。我使用会话数据从客户表中获取数据。但是我无法进行个人资料编辑。我遇到这个错误。

这是我的观点:

<section class="panel">
                    <div class="bio-graph-heading">
                        <?php echo $this->lang->line('profile_edit_top_text'); ?>
                    </div>
                    <div class="panel-body bio-graph-info">
                        <h1> <?php echo $this->lang->line('profile_edit_text_informations'); ?></h1>
                        <form class="form-horizontal" role="form" method="post" action="<?php echo base_url("CProfile_edit/update/$user->cosId"); ?>">
                            <!-- Form -->
                            <div class="form-group">
                                <label  class="col-lg-2 control-label"><?php echo $this->lang->line('cprofile_profile_username'); ?></label>
                                <div class="col-lg-6">
                                    <input type="text" class="form-control" id="f-name" name="cosUserName" placeholder="<?php echo $this->session->userdata('people_username'); ?>" />
                                </div>
                            </div>
                            <!-- Form -->
                            <div class="form-group">
                                <label  class="col-lg-2 control-label"><?php echo $this->lang->line('cprofile_profile_email'); ?></label>
                                <div class="col-lg-6">
                                    <input type="email" class="form-control" id="email" name="cosEmail" placeholder="<?php echo $this->session->userdata('people_email'); ?>" />
                                </div>
                            </div>
                            <!-- Form -->
                            <div class="form-group">
                                <label  class="col-lg-2 control-label"><?php echo $this->lang->line('cprofile_profile_firstname'); ?></label>
                                <div class="col-lg-6">
                                    <input type="text" class="form-control" id="f-name" name="cosName" placeholder="<?php echo $this->session->userdata('people_username'); ?>" />
                                </div>
                            </div>
                            <!-- Form -->
                            <div class="form-group">
                                <label  class="col-lg-2 control-label"><?php echo $this->lang->line('cprofile_profile_lastname'); ?></label>
                                <div class="col-lg-6">
                                    <input type="text" class="form-control" id="l-name" name="cosSurname" placeholder="<?php echo $this->session->userdata('people_surname'); ?>" />
                                </div>
                            </div>
                            <!-- Form -->
                            <div class="form-group">
                                <label  class="col-lg-2 control-label"><?php echo $this->lang->line('cprofile_profile_phone'); ?></label>
                                <div class="col-lg-6">
                                    <input type="text" class="form-control" id="f-name" name="cosPho" placeholder="<?php echo $this->session->userdata('people_phone'); ?>" />
                                </div>
                            </div>
                            <!-- Form -->
                            <div class="form-group">
                                <label  class="col-lg-2 control-label"><?php echo $this->lang->line('cprofile_profile_mobile'); ?></label>
                                <div class="col-lg-6">
                                    <input type="text" class="form-control" id="f-name" name="cosGsm" placeholder="<?php echo $this->session->userdata('people_mobile'); ?>" />
                                </div>
                            </div>
                            <!-- Basic select -->
                            <div class="form-group">
                                <label class="control-label col-lg-3"><?php echo $this->lang->line('cprofile_profile_lang'); ?> <span class="text-danger">*</span></label>
                                <div class="col-lg-9">
                                    <select name="cosLang" class="form-control">
                                        <option value="<?php echo $this->session->userdata('people_lang'); ?>"><?php echo $this->session->userdata('people_lang'); ?></option>
                                        <option value="en">English</option>
                                        <option value="ar">Arabic</option>
                                    </select>
                                </div>
                            </div>
                            <!-- /basic select -->
                            <div class="form-group">
                                <div class="col-lg-offset-2 col-lg-10">
                                    <button type="submit" class="btn btn-success">Save</button>
                                    <button type="button" class="btn btn-default">Cancel</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </section>

有我的控制器:

 <?php
defined('BASEPATH') OR exit('No direct script access allowed');

class CProfile_edit extends CI_Controller {

    public function index()
    {
        //redirect(base_url('calendar'));
        $this->lang->load('content', $this->session->userdata('people_lang'));
        $this->load->view('cprofile_edit');
    }


    public function update($cusId = 1)
    {
        if (! empty($cusId))
        {
            $data = array (
                "cosUserName" => $this->input->post("cosUserName"),
                "cosEmail" => $this->input->post("cosEmail"),
                "cosName" => $this->input->post("cosName"),
                "cosSurname" => strtoupper($this->input->post("cosSurname")),
                "cosPho" => $this->input->post("cosPho"),
                "cosGsm" => $this->input->post("cosGsm"),
                "cosLang" => $this->input->post("cosLang"),
                "cosEditDate" => date('Y-m-d H:i:s')
            );

            $update = $this->db->where("cusId", $cusId)->update("customer", $data);
            if($update)
            {
                redirect(base_url("cprofile"));
            }
            else
            {
                echo "Hata!";
            }
        }
    }


}
?>

行号:14错误:public function update($cusId) {

1 个答案:

答案 0 :(得分:1)

编辑视图并使用此代码。

               <section class="panel">
                    <div class="bio-graph-heading">
                        <?php echo $this->lang->line('profile_edit_top_text'); ?>
                    </div>
                    <div class="panel-body bio-graph-info">
                        <h1> <?php echo $this->lang->line('profile_edit_text_informations'); ?></h1>
                        <form class="form-horizontal" role="form" method="post" action="<?php echo base_url("CProfile_edit/update/".$this->session->userdata('people_id')); ?>">
                            <!-- Form -->
                            <div class="form-group">
                                <label  class="col-lg-2 control-label"><?php echo $this->lang->line('cprofile_profile_username'); ?></label>
                                <div class="col-lg-6">
                                    <input type="text" class="form-control" id="f-name" name="cosUserName" placeholder="<?php echo $this->session->userdata('people_username'); ?>" />
                                </div>
                            </div>
                            <!-- Form -->
                            <div class="form-group">
                                <label  class="col-lg-2 control-label"><?php echo $this->lang->line('cprofile_profile_email'); ?></label>
                                <div class="col-lg-6">
                                    <input type="email" class="form-control" id="email" name="cosEmail" placeholder="<?php echo $this->session->userdata('people_email'); ?>" />
                                </div>
                            </div>
                            <!-- Form -->
                            <div class="form-group">
                                <label  class="col-lg-2 control-label"><?php echo $this->lang->line('cprofile_profile_firstname'); ?></label>
                                <div class="col-lg-6">
                                    <input type="text" class="form-control" id="f-name" name="cosName" placeholder="<?php echo $this->session->userdata('people_username'); ?>" />
                                </div>
                            </div>
                            <!-- Form -->
                            <div class="form-group">
                                <label  class="col-lg-2 control-label"><?php echo $this->lang->line('cprofile_profile_lastname'); ?></label>
                                <div class="col-lg-6">
                                    <input type="text" class="form-control" id="l-name" name="cosSurname" placeholder="<?php echo $this->session->userdata('people_surname'); ?>" />
                                </div>
                            </div>
                            <!-- Form -->
                            <div class="form-group">
                                <label  class="col-lg-2 control-label"><?php echo $this->lang->line('cprofile_profile_phone'); ?></label>
                                <div class="col-lg-6">
                                    <input type="text" class="form-control" id="f-name" name="cosPho" placeholder="<?php echo $this->session->userdata('people_phone'); ?>" />
                                </div>
                            </div>
                            <!-- Form -->
                            <div class="form-group">
                                <label  class="col-lg-2 control-label"><?php echo $this->lang->line('cprofile_profile_mobile'); ?></label>
                                <div class="col-lg-6">
                                    <input type="text" class="form-control" id="f-name" name="cosGsm" placeholder="<?php echo $this->session->userdata('people_mobile'); ?>" />
                                </div>
                            </div>
                            <!-- Basic select -->
                            <div class="form-group">
                                <label class="control-label col-lg-3"><?php echo $this->lang->line('cprofile_profile_lang'); ?> <span class="text-danger">*</span></label>
                                <div class="col-lg-9">
                                    <select name="cosLang" class="form-control">
                                        <option value="<?php echo $this->session->userdata('people_lang'); ?>"><?php echo $this->session->userdata('people_lang'); ?></option>
                                        <option value="en">English</option>
                                        <option value="ar">Arabic</option>
                                    </select>
                                </div>
                            </div>
                            <!-- /basic select -->
                            <div class="form-group">
                                <div class="col-lg-offset-2 col-lg-10">
                                    <button type="submit" class="btn btn-success">Save</button>
                                    <button type="button" class="btn btn-default">Cancel</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </section>