//将修改的信息存入数据库 <?php header("Content-type:text/html; charset=utf-8"); //通过post获取页面提交数据信息 $data = $_POST; //print_r($data); include_once "connect.php"; $sql = "update `user` set username='{$data['username']}',password='{$data['password']}', email='{$data['email']}',sex='{$data['sex']}',txt='{$data['txt']}' whereid']}'"; echo $sql; $res = mysql_query($sql,$link); if($res){ header("Location:hello.php"); //echo "alert('修改成功')"; }else{ header("Location:update1.php?id=".$data['id']); //echo "alert('修改失败')"; } ?>
6.删除数据
//删除数据库里的数据 <?php header("Content-type:text/html; charset=utf-8"); include_once 'connect.php'; $sql = "delete from user whereid']."'"; $sus=mysql_query($sql,$link); if($sus){ header("location:hello.php"); }else{ echo "alert('删除失败')"; } ?> //若要删除李四,点击删除后,会自动跳转到后台页面,数据库里数据也删除