您好我正在使用datagrid。我已完成分页和编辑现在我遇到删除问题。在分页中,它会自动在一页中创建页面。这是我打电话的代码
$deletetUrl = "admin.php?page=delete_user&id=".$data["user_id"]."&pageid=".$pageNumber." ";
$delete = "<a href='".$deletetUrl."'><img src='".$assets."edit-delete.png' alt='Delete' title='Delete' border='0' height='16' width='16'></a>";
进入此页面
<?php
echo $query = "Delete from user where user_id=$_GET[id]";
$result = mysql_query($query);
?>
<script type="text/javascript">
window.location="admin.php?page=view_user&pageid=<?php echo urlencode($_GET[pageid]); ?>"
</script>
它完全删除并且使用这个javascript函数它返回它转到记录的第1页,虽然我从另一个页面删除。请让我如何在同一页面上删除我在这种情况下删除记录的内容,或者任何人都可以提出可以提出解决方案的小型ajax功能
答案 0 :(得分:1)
<?php
/* You should sanitize the $_GET['id'] input & restrict access to this page as
your vulnerable to sql injection as posting ?id=1 would most likely delete your admin user
*/
$query = "Delete from user where user_id=$_GET[id]";
$result = mysql_query($query);
header('Location: admin.php?pageid='.$_REQUEST['pageid']);
?>