隨筆 - 78  文章 - 25  trackbacks - 0
          <2015年7月>
          2829301234
          567891011
          12131415161718
          19202122232425
          2627282930311
          2345678

          常用鏈接

          留言簿

          隨筆分類(75)

          隨筆檔案(78)

          相冊

          實用Links

          我的Links

          搜索

          •  

          積分與排名

          • 積分 - 114320
          • 排名 - 515

          最新評論

          閱讀排行榜

          評論排行榜

          php插入數據頁面insertData.php
          <html>
              <head>
                  <title>向數據庫中插入數據</title>
              </head>
              <body>
                  <center>
                      <form name="myForm" method="post" action="processInsertData.php">
                          <table bgcolor="cyan">
                              <tr>
                                  <td>學號</td>
                                  <td><input type="text" name="txtId"  /></td>
                              </tr>
                              <tr>
                                  <td>姓名</td>
                                  <td><input type="text" name="txtName" /></td>
                              </tr>
                              <tr>
                                  <td>年齡</td>
                                  <td><input type="text" name="txtAge"></td>
                              </tr>
                              <tr>
                                  <td>性別</td>
                                  <td>
                                      <select name="sSex">
                                          <option value="male">male</option>
                                          <option value="female">female</option>
                                      </select>
                                  </td>
                              </tr>
                              <tr>
                                  <td>地址</td>
                                  <td><input type="text" name="txtAddress"/></td>
                              </tr>
                              <tr>
                                  <td colspan="2" align="center">
                                      <input type="submit" name="submit" value="添加"/>
                                      <input type="reset" name="reset" value="重置">
                                  </td>
                              </tr>
                          </table>
                      </form>
                  </center>
              </body>
          </html>


          處理數據插入頁面processInsertData.php
          <?php
              $link=mysql_connect("localhost","root","root");
              mysql_select_db("rorely");
              $id=$_POST['txtId']|null;
              $name=$_POST['txtName'];
              $age=$_POST['txtAge'];
              $sex=$_POST['sSex'];
              $address=$_POST['txtAddress'];

              $exec="insert into test values($id,'$name',$age,'$sex','$address')";
              $result=mysql_query($exec);
              if($result) echo "學生已添加到數據表中<br>";
              else echo "該學生沒有添加進數據表,請重新輸入。<br>";
              mysql_close();
          ?>
          <a href="insertData.php">返回添加頁面</a>

          posted on 2009-07-01 14:03 期待明天 閱讀(6039) 評論(7)  編輯  收藏 所屬分類: PHP

          FeedBack:
          # re: php 向數據庫表中插入數據 2010-01-20 13:34 嗷嗷嗷
          大沙發的法定的  回復  更多評論
            
          # re: php 向數據庫表中插入數據[未登錄] 2012-09-03 13:37 123
          去問去問去問去問  回復  更多評論
            
          # re: php 向數據庫表中插入數據[未登錄] 2012-09-03 13:38 123
          @嗷嗷嗷
          去問去問去問  回復  更多評論
            
          # re: php 向數據庫表中插入數據 2012-11-28 22:16 徐小松
          請問為什么我從網頁上輸入數據后,$_post[]中的內容是空的呀?  回復  更多評論
            
          # re: php 向數據庫表中插入數據 2013-03-29 15:11 鵝鵝鵝鵝鵝鵝餓
          熱歌  回復  更多評論
            
          # re: php 向數據庫表中插入數據 2014-09-11 10:34 dgh
          dthd  回復  更多評論
            
          # re: php 向數yio據庫表中插入數據 2015-07-16 22:30 yuio
          uiol  回復  更多評論
            
          主站蜘蛛池模板: 方城县| 大厂| 江永县| 原阳县| 宜兴市| 深水埗区| 曲阜市| 通化市| 阳新县| 宁远县| 区。| 米泉市| 山阳县| 永平县| 武川县| 昆山市| 宝坻区| 拜城县| 萨迦县| 卢氏县| 光泽县| 乡宁县| 共和县| 营山县| 平陆县| 旬邑县| 贵港市| 德惠市| 黄梅县| 奇台县| 泗阳县| 昌吉市| 抚顺市| 青川县| 革吉县| 弥渡县| 宜宾市| 晋宁县| 德庆县| 通江县| 青川县|