解决方案 »

  1.   

     action 属性规定当提交表单时,向何处发送表单数据,你提交给了show.php,而你的插入语句写在本文件里面啊
      

  2.   


    不是
    下面这个是
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>留言板</title>
    <style type="text/css">
    a{text-decoration:none;}
    body h1{text-align:center;}
    .tr1{background-color:yellow;}
    .tr1 td{width:100px;}
    .tr2 td{height:80px;}
    </style>
    <?php 
     include_once 'conn.php';
     $url = $_SERVER['REQUEST_URI'];
     $url = parse_url($url);
     $url = $url[path];
    ?>
    </head>
    <body>
    <h1>留言查看</h1>
    <?php 
    $query = mysql_query("select * from infor");

    $num = mysql_num_rows($query);

    while ($row = mysql_fetch_array($query)){
    ?>
    <table cellpadding="0" cellspacing="0" border="1" align="center">
    <tr class="tr1">
    <td>ID:<?php echo $row['id'];?></td>
    <td>姓名:<?php echo $row['name'];?></td>
    <td>标题:<?php echo $row['title'];?></td>
    </tr>
    <tr class="tr2">
    <td colspan="3">内容:<?php echo $row['content'];?></td>
    </tr>
    <br>
    </table>
    <?php }?>
    </body>
    </html>
      

  3.   

    form 的action是指定表单的处理文件,你的show.php 都没有插入语句,怎么能插入到数据库呢。
      

  4.   

    PHP插入数据信息示例
    //需要插入数据库的内容
    <form action="show.php" method="post" style="margin-top:550px;margin-left:50px;">
    姓名:<input type="text" name="name"><br/><br/>
    标题:<input type="text" name="title"><br/><br/>
    内容:<textarea cols="15" rows="4" name="content"></textarea><br/><br/>
    <input value="提交" name="submit" type="submit">
    <input value="重置" name="reset" type="reset">
    //show.php页面设置插入tb_note数据库
    <?php
    $name =$_POST['name'];
    $title = $_POST['title'];
    $content= $_POST['content'];
    $query=mysql_query("insert into tb_note (name,title,content) values('    $name','$title’,’$content')”.$conn);
    if($query==true) {echo "<script>alert('上传插入成功!');window.location.href='index.php';</script>";
    }//CodeGo.net/
    Else{
    echo "<script language='javascript'>alert('对不起,插入失败!');history.back();</script>";
    }
    ?>
      

  5.   

    因为是你当前页面操作,要么在form的action正确指向操作的文件,要么action默认为空。