隨筆 - 78  文章 - 25  trackbacks - 0
          <2014年9月>
          31123456
          78910111213
          14151617181920
          21222324252627
          2829301234
          567891011

          常用鏈接

          留言簿

          隨筆分類(75)

          隨筆檔案(78)

          相冊(cè)

          實(shí)用Links

          我的Links

          搜索

          •  

          積分與排名

          • 積分 - 114332
          • 排名 - 515

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          php插入數(shù)據(jù)頁面insertData.php
          <html>
              <head>
                  <title>向數(shù)據(jù)庫(kù)中插入數(shù)據(jù)</title>
              </head>
              <body>
                  <center>
                      <form name="myForm" method="post" action="processInsertData.php">
                          <table bgcolor="cyan">
                              <tr>
                                  <td>學(xué)號(hào)</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>


          處理數(shù)據(jù)插入頁面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 "學(xué)生已添加到數(shù)據(jù)表中<br>";
              else echo "該學(xué)生沒有添加進(jìn)數(shù)據(jù)表,請(qǐng)重新輸入。<br>";
              mysql_close();
          ?>
          <a href="insertData.php">返回添加頁面</a>

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

          FeedBack:
          # re: php 向數(shù)據(jù)庫(kù)表中插入數(shù)據(jù) 2010-01-20 13:34 嗷嗷嗷
          大沙發(fā)的法定的  回復(fù)  更多評(píng)論
            
          # re: php 向數(shù)據(jù)庫(kù)表中插入數(shù)據(jù)[未登錄] 2012-09-03 13:37 123
          去問去問去問去問  回復(fù)  更多評(píng)論
            
          # re: php 向數(shù)據(jù)庫(kù)表中插入數(shù)據(jù)[未登錄] 2012-09-03 13:38 123
          @嗷嗷嗷
          去問去問去問  回復(fù)  更多評(píng)論
            
          # re: php 向數(shù)據(jù)庫(kù)表中插入數(shù)據(jù) 2012-11-28 22:16 徐小松
          請(qǐng)問為什么我從網(wǎng)頁上輸入數(shù)據(jù)后,$_post[]中的內(nèi)容是空的呀?  回復(fù)  更多評(píng)論
            
          # re: php 向數(shù)據(jù)庫(kù)表中插入數(shù)據(jù) 2013-03-29 15:11 鵝鵝鵝鵝鵝鵝餓
          # re: php 向數(shù)據(jù)庫(kù)表中插入數(shù)據(jù) 2014-09-11 10:34 dgh
          # re: php 向數(shù)yio據(jù)庫(kù)表中插入數(shù)據(jù) 2015-07-16 22:30 yuio
          主站蜘蛛池模板: 韶关市| 大渡口区| 固安县| 杭州市| 石泉县| 会东县| 北票市| 政和县| 吴川市| 石柱| 安丘市| 合川市| 沙洋县| 沐川县| 梧州市| 眉山市| 兰州市| 新龙县| 胶南市| 洞头县| 民和| 昌宁县| 柘城县| 河曲县| 玉门市| 铜梁县| 和龙市| 外汇| 白玉县| 西乌珠穆沁旗| 历史| 丹东市| 临沂市| 深泽县| 高密市| 贵州省| 玉树县| 甘孜| 武强县| 方正县| 农安县|