/** * 登录页面 */ public function login() { if (IS_POST) { $model = D('Member'); if ($model->create() !== false) { $userinfo = $model->login(); if (is_array($userinfo)) { //将用户数据保存到session login($userinfo); //从用户中取出ID作为UID defined('UID') or define('UID', $userinfo['id']); //将cookie中的商品保存到数据库中 $shoppingCarModel = D('ShoppingCar'); $shoppingCarModel->cookie2db(); $url = U('Index/index'); if (cookie('__login_return_url__')) { $url = cookie('__login_return_url__'); cookie('__login_return_url__', null); } $this->success('登陆成功!', $url); return; } } $this->error(get_model_error($model)); } else { $this->assign('title', '登录商城'); $this->display('login'); } }
/** * 地址的添加 */ public function add() { if (IS_POST) { if (($data = $this->model->create()) !== false) { if (empty($data['id'])) { if (($id = $this->model->add($this->usePostParams ? I('post.') : '')) !== false) { $this->success($id, cookie('__FORWORD__')); return; } } else { //有id的值,则为编辑 if ($this->model->save() !== false) { $this->success($data['id'], cookie('__FORWORD__')); return; } } } $this->error('操作失败' . get_model_error($this->model)); } else { $this->_edit_view_before(); $this->assign('meta_title', '添加' . $this->meta_title); $this->display('edit'); } }
echo $req; ?> <?php echo get_model_error("b_zip", $payment); ?> </td> </tr> <tr> <td><label for="b_phone">Phone:</label></td> <td><?php echo model_text_field($payment, "b_phone", array("id" => 'b_phone', "class" => 'form_text', "size" => "20", "maxlength" => "20")); echo $req; ?> <i>(e.g. 888-555-1212)</i><?php echo get_model_error("b_phone", $payment); ?> </td> </tr> </tbody> </table> </div> </div> <?php } // payment_required ?> <h3>Notifications</h3>
/** * 供应商的编辑 * @param $id 数据ID */ public function edit($id) { if (IS_POST) { if ($this->model->create() !== false) { if ($this->model->save($this->usePostParams ? I('post.') : '') !== false) { $this->success('修改成功', cookie('__FORWORD__')); return; } } $this->error('操作失败' . get_model_error($this->model)); } else { $this->_edit_view_before(); $row = $this->model->find($id); $this->assign($row); $this->assign('meta_title', '编辑' . $this->meta_title); $this->display('edit'); } }