-1
我有一个PHP脚本,一切正常,即使是GET
方法,但它没有删除任何东西。为什么我的PHP删除脚本不起作用?
这是第一个脚本的重要部分,当图像被点击时,与其相关的用户条目应该被删除。
echo'<form method="GET" action="_delete.php"> <input type="hidden" name="username" value='.$username.'> </input><a onclick="form.submit();" href="_delete.php?username='.$username.'&send=Submit">';
这是怎么我的GET
方法被处理:
if(isset($_GET['send']))
{
$selector=$_GET['username'];
$sql="DELETE * FROM user WHERE user_name = '$selector'";
$result=$SQL->query($sql);//SQL is my mysqli connection as I specified at
//the top of the code but 'cause this all works already it's not important here.
if($result==0)
{
echo'<p>this works</p>';
echo'<meta http-equiv="refresh" content="3; URL=user.php">';
}
else{
echo'<p>gg</p>';
echo'<meta http-equiv="refresh" content="3; URL=user.php">';
}
}
的GET
方法有效,因为它就像我之前指定的呼应this works
。
我知道,这不是最好的方式,但不幸的是在我的项目中没有其他选择。
我觉得prblem这里'$ SQL = “DELETE * FROM用户其中user = '$选择'”;'更改为' $ sql =“DELETE FROM user WHERE user_name ='$ selector'”;' – Shehary
yep.Problem解决了,谢谢!! – Needforbleed