<html>
 <body>
 <form action="action.php" method="post">
 <p>姓名: <input type="text" name="name" /></p>
 <p>
   <label></label>
   <label>确认修改
   <input type="submit" name="Submit" value="提交">
   </label>
 </p>
 </form></body>
</html><?php
$servername='DRIVER={SQL Server};SERVER=turboryan;DATABASE=crm5'; 
$username = 'sa'; 
$password = 'sa'; 
$conn = odbc_connect($servername,$username,$password); $sql="select top 1 friend_name from tc_friend"; $rs=odbc_exec($conn,$sql); while (odbc_fetch_row($rs)) ;  {   $compname=odbc_result($rs,"friend_name");   echo "$compname<br>";   } odbc_close($conn); ?>
我想点提交后,就将friend_name修改成 text姓名里的内容,请教怎么写

解决方案 »

  1.   

    <html> 
    <body> 
    <form action="action.php" method="post"> 
    <p>姓名: <input type="text" name="name" /> </p> 
    <p> 
      <label> </label> 
      <label>确认修改 
      <input type="submit" name="Submit" value="提交"> 
      <input type='hidden' name'ID' value='1'>
      </label> 
    </p> 
    </form> </body> 
    </html> <?php 
    $servername='DRIVER={SQL Server};SERVER=turboryan;DATABASE=crm5'; 
    $username = 'sa'; 
    $password = 'sa'; 
    $conn = odbc_connect($servername,$username,$password); if ($_POST[Submit])
    {
       $sql="update tc_friend set friend_name='".$_POST[name]."' where ID='".$_POST[ID]."'";   odbc_exec($conn,$sql);
    }$sql="select top 1 friend_name from tc_friend"; $rs=odbc_exec($conn,$sql); while (odbc_fetch_row($rs)) ;   {   $compname=odbc_result($rs,"friend_name");   echo "$compname <br>";   } odbc_close($conn); ?> 
      

  2.   

    跳转入http://localhost/action.php
    内容是无法显示页面