zoukankan      html  css  js  c++  java
  • phpcms前台的控制器

    留言板测试玩的!

    <?php
    defined('IN_PHPCMS') or exit('No permission resource');


    class index{
    private $db;
    function __construct(){
    $siteid=isset($_GET['siteid'])?intval($_GET['siteid']):get_siteid();
    define(SITEID,$siteid);
    //加载模型
    $this->db=pc_base::load_model(guestbook_model);
    $this->tableName="v9_guestbook";
    }

    //默认的方法
    public function init(){
    $siteid=SITEID;
    $setting=getcache('guestbook','commons');
    $SEO=seo(SITEID,'',L('guestbook'),'','');

    $array=$this->db->select();
    /*echo "<pre>";
    print_r($this->db);
    echo "</pre>";
    print_r($array);*/
    include template('guestbook','index');
    }




    //留言方法
    public function liuyan(){
    $siteid=SITEID;
    if(isset($_POST['lysubmi'])){
    //验证字段
    if($_POST['title']==""){
    showmessage(L('title_noempty'),"?m=guestbook&c=index&a=liuyan&siteid=$siteid");
    }
    if($_POST['content']==''){
    showmessage(L('content_noempty'),"?m=guestbook&c=index&a=liuyan&siteid=$siteid");
    }
    if($_POST['email']==''){
    showmessage(L('email_onerror'),"?m=guestbook&c=index&a=liuyan&siteid=$siteid");
    }
    if($_POST['qq']==''){
    showmessage(L('qq_onerror'),"?m=guestbook&c=index&a=liuyan&siteid=$siteid");
    }


    //安全过滤字段
    $title=safe_replace($_POST['title']);
    $content=safe_replace($_POST['content']);
    $email=safe_replace($_POST['email']);
    $qq=safe_replace($_POST['qq']);

    $data=array('title'=>$title,'content'=>$content,'email'=>$emial,'qq'=>$qq);
    $insert_id=$this->db->insert($data,$this->tableName,true);
    if($insert_id>0){
    echo "插入数据库成功!";
    }

    }else{
    include template("guestbook","liuyan");

    }

    }
    }
    ?>

  • 相关阅读:
    NYOJ-开灯问题
    cocos2dx 3.0 飞机大战
    Java 实现享元(Flyweight)模式
    MongoDB 操作手冊CRUD查询指针
    均值滤波
    cxf调用c#的webservice
    SharePoint 2013 术语和术语集介绍
    Unity3d 网络编程(二)(Unity3d内建网络各项參数介绍)
    linux服务器在运行210天左右宕机
    好的用户界面-界面设计的一些技巧
  • 原文地址:https://www.cnblogs.com/yuwensong/p/2946210.html
Copyright © 2011-2022 走看看