thinkphp3.2 留言板内容提交到数据库

1.配置


<?php
return array(
    //'配置项'=>'配置值'
    'DEFAULT_MODULE'        =>  'Admin',  // 默认模块
    'DEFAULT_CONTROLLER'    =>  'Index', // 默认控制器名称
    'DEFAULT_ACTION'        =>  'index', // 默认操作名称




    'DB_TYPE'               =>  'mysqli',     // 数据库类型
    'DB_HOST'               =>  'localhost', // 服务器地址
    'DB_NAME'               =>  'thinkphp0421',          // 数据库名
    'DB_USER'               =>  'root',      // 用户名
    'DB_PWD'                =>  'root',          // 密码
    'DB_PORT'               =>  '3306',        // 端口
   
    'DB_FIELDS_CACHE'       =>  true,        // 启用字段缓存


    'URL_MODEL'             =>   0,// 0 普通模式, 1, pathinfo模式 ,2. rewirte模式  3. 兼容模式


    'SHOW_PAGE_TRACE'        =>    true,  //打开Trace Page 调试页
//    'TMPL_ENGINE_TYPE'      =>'smarty'
  
);




----------**-----------------------**------- <br>


2. 前端代码  /tp-ceshi/Application/Admin/View/Goods/edit.html




<!-- $Id: brand_info.htm 14216 2008-03-10 02:27:21Z testyang $ -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>ECSHOP 管理中心 - {$meta_title} </title>
<meta name="robots" content="noindex, nofollow">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="__CSS__/general.css" rel="stylesheet" type="text/css" />
<link href="__CSS__/main.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>
    <span class="action-span"><a href="brandList.html">商品商品</a></span>
    <span class="action-span1"><a href="#">ECSHOP 管理中心</a></span>
    <span id="search_id" class="action-span1"> - {$meta_title} </span>
    <div style="clear:both"></div>
</h1>
<div class="main-div">
    <form method="post" action="{:U()}" enctype="multipart/form-data" >
        <table cellspacing="1" cellpadding="3" width="100%">
            <tr>
                <td class="label">商品名称</td>
                <td>
                    <input type="text" name="goods_name" maxlength="60" value="{$goods->goods_name}" />
                    <span class="require-field">*</span>
                </td>
            </tr>
            <tr>
                <td class="label">商品价格</td>
                <td>
                    <input type="text" name="goods_price" value="{$goods:goods_price}" />
                </td>
            </tr>
            <tr>
                <td class="label">商品数量</td>
                <td>
                    <input type="text" name="goods_number" value="{$goods_number}" />
                </td>
            </tr>
            <tr>
                <td class="label">商品描述</td>
                <td>
                    <textarea  name="goods_introduce" cols="60" rows="4"  ></textarea>
                </td>
            </tr>
            <tr>
                <td colspan="2" align="center"><br />
                    <input type="submit" class="button" value=" 确定 " />
                    <input type="reset" class="button" value=" 重置 " />
                </td>
            </tr>
        </table>
    </form>
</div>


<div id="footer">
共执行 1 个查询,用时 0.018952 秒,Gzip 已禁用,内存占用 2.197 MB<br />
版权所有 &copy; 2005-2012 上海商派网络科技有限公司,并保留所有权利。</div>
</body>
</html>
------------------------***-------------------------**----------------<br>


3.模型   /tp-ceshi/Application/Admin/Model/GoodsModel.class.php


<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 14-6-23
 * Time: 下午2:08
 */


namespace Admin\Model;




use Think\Model;


class GoodsModel extends Model{




    


}
---------------------**---------------------------------***----------------------<br>




4. 控制器  /tp-ceshi/Application/Admin/Controller/GoodsController.class.php


<?php


namespace Admin\Controller;




use Think\Controller;


class GoodsController extends Controller{
    
public function add(){

if(IS_POST){
$goodsModel = D('Goods');
$goodsModel->create();
if($goodsModel->add(I('post'))){
$this->success('保存成功',U('index'));

}else{
$this->error('保存失败!'.$goodsModel->getError());
}

}else{
$this->display('edit');

}






}
    
    







}    


-----------------------**---------------------------------**---------------------<br>


5. 数据库  thinkphp0421   ---> goods.sql


 数据库


/*
Navicat MySQL Data Transfer


Source Server         : root
Source Server Version : 50540
Source Host           : localhost:3306
Source Database       : thinkphp0421


Target Server Type    : MYSQL
Target Server Version : 50540
File Encoding         : 65001


Date: 2015-11-22 05:06:33
*/


SET FOREIGN_KEY_CHECKS=0;


-- ----------------------------
-- Table structure for goods
-- ----------------------------
DROP TABLE IF EXISTS `goods`;
CREATE TABLE `goods` (
  `goods_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id',
  `goods_name` varchar(128) COLLATE utf8_unicode_ci NOT NULL DEFAULT '' COMMENT '商品名称',
  `goods_price` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '价格',
  `goods_number` int(11) NOT NULL DEFAULT '100' COMMENT '数量',
  `goods_introduce` text COLLATE utf8_unicode_ci COMMENT '详细介绍',
  `goods_big_img` varchar(128) COLLATE utf8_unicode_ci NOT NULL DEFAULT '' COMMENT '商品图片',
  `goods_small_img` varchar(128) COLLATE utf8_unicode_ci NOT NULL DEFAULT '' COMMENT '商品小图',
  `goods_create_time` int(11) NOT NULL DEFAULT '0' COMMENT '添加时间',
  `goods_last_time` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`goods_id`)
) ENGINE=InnoDB AUTO_INCREMENT=56 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='商品表';


-- ----------------------------
-- Records of goods
-- ----------------------------
INSERT INTO `goods` VALUES ('1', '1', '0.00', '100', '1', '1', '1', '0', '0');
INSERT INTO `goods` VALUES ('2', '2', '0.00', '2', '1', '1', '1', '0', '0');




-------------------**---------------------------***------------<br>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值