php+mysql


<form action="" method="post">
    <table class="opt">
     <tr>
      <th colspan="2">新闻标题:</th>
     </tr>
     <tr>
      <td><input type="text" class="txt" style="width: 500px" name="title" /></td>
      <td></td>
     </tr>
     <tr>
      <th colspan="2">新闻内容:</th>
     </tr>
     <tr>
      <td><textarea class="area" style="width: 600px;height: 100px" name="content"></textarea></td>
      <td valign="top"></td>
     </tr>
    
     
    </table>
    <div class="opt"><input type="submit" name="submit" value=" 发 布 " class="btn" tabindex="3" /></div>
   </form>
           
           
           
           
            <?php

$conn=mysql_connect ("localhost", "root", "数据库密码");
mysql_select_db("newstest");
$exec="insert into newstable(newsTitle,newsContent) values('".$_POST[title]."','".$_POST[content]."')";

mysql_query("set character set gb2312");
$result=mysql_query($exec);
echo "<font color=red size=12px>添加新闻成功!</font>";

?>

posted on 2008-07-10 08:57  超少  阅读(500)  评论(2编辑  收藏  举报