当前位置:编程学习 > php >>

php实战第二天

\
 


1.我的留言板上写上了 add方法


[php]  function add(){ 
    //添加后返回 影响条数,如果大于0就说明添加成功  
    if($this->db->data($_POST)->add()>0){ 
        echo "添加成功"; 
        //  echo "<script>location.reload()</script>";//防止刷新后的表单的重复提交  
        Header("HTTP/1.1 303 See Other"); 
        Header("Location: ");   //转向到根目录  
        exit; 
         
    }else { 
        die($this->db->error());//添加失败输出错误信息  
    }    

  function add(){
   //添加后返回 影响条数,如果大于0就说明添加成功
   if($this->db->data($_POST)->add()>0){
    echo "添加成功";
    // echo "<script>location.reload()</script>";//防止刷新后的表单的重复提交
    Header("HTTP/1.1 303 See Other");
    Header("Location: ");   //转向到根目录
    exit;
    
   }else {
    die($this->db->error());//添加失败输出错误信息
   } 
  }对应提交表单


[html]  <div class="center"> 
    <form action="?m=index&a=add" method="post"> 
        <table border=0> 
                        <tr> 
                            <td>用户名</td> 
                            <td><input type="text" name="userName" value="admin"></td> 
                        </tr> 
                        <tr> 
                            <td>留言内容</td> 
                            <td><textarea rows="3" cols="20" name="content">aaaaa</textarea></td> 
                        </tr> 
                        <tr> 
                            <td>电子邮箱</td> 
                            <td>email:<input type="text" name="email" value="admin@admin.com"></td> 
                        </tr> 
                        <tr> 
                            <td></td> 
                            <td><input type="submit" name="submit" value="留言"></td> 
                        </tr> 
        </table> 
             
                    <input type="hidden" name="action" value="add"> 
                </form> 
            </div> 
</div> 

<div class="center">
 <form action="?m=index&a=add" method="post">
   <table border=0>
                        <tr>
                            <td>用户名</td>
                            <td><input type="text" name="userName" value="admin"></td>
                        </tr>
                        <tr>
                            <td>留言内容</td>
                            <td><textarea rows="3" cols="20" name="content">aaaaa</textarea></td>
                        </tr>
                        <tr>
     

补充:Web开发 , php ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,