PHP删除代码调用不到

来源:百度知道 编辑:UC知道 时间:2024/06/05 16:49:10
<a href="liuyan_save.php?action=del&id=<?=$row[0]?>" >删除</a>

include("inc/conn.php");

$action=$_POST['action'];
$username=$_POST['username'];
$sex=$_POST['sex'];
$ages=$_POST['ages'];
$title=$_POST['title'];
$content=$_POST['content'];
$showtime=date("Y-m-d");
$loveing=request("loveing",",","post");

switch ($action)
{
case "add":
{
$sql="insert into info (username,sex,ages,loveing,title,content,adddatetime) values ('$username','$sex','$ages','$loveing','$title','$content','$showtime')";
mysql_query("set names 'utf8'");
mysql_query($sql,$dblink);
echo "<script language='Javascript'>alert('添加成功');location.href='inde

首先 你的switch 没有break; 这是一个问题

删除不了是因为参数传错了 $id 不存在

$id=$_POST["id"];
改成
$id=$_GET["id"];
或者
$id=intval($_GET["id"]);

推荐用
$id=intval($_GET["id"]);
可以过滤数据,相对安全

switch
case:
breaak;
case:
break;