链接的 isset - PHP
我正在尝试创建一个链接供用户单击,将其从列表中删除。我试图弄清楚如何在不使用提交按钮且不使用 $_GET(如果可能)的情况下执行此操作。
不管怎样,我害怕用 $_GET 来做到这一点(我现在的方式),因为用户可以在 URL 中输入这个(即使 99% 的人不知道如何或不知道如何做到这一点),他们会从列表中删除。
如何命名链接以便可以使用 $_POST?
$attendingUsers = mysql_query("Select acceptedInvites from events where eventID = ".mysql_real_escape_string($_GET['eventID'])." ");
$users= mysql_fetch_array($attendingUsers);
$user = $users['acceptedInvites'];
if(preg_match("/$userid/", $user)){
echo "You are attending this event</br>";
echo '<a href="viewevent.php?eventID='.$_GET['eventID'].'&delete=1">Click here </a>to remove yourself from the list';
if($_GET['delete']=1){
$sql=...
}
}
不使用 $_GET 是否可以做到这一点?谢谢!
I'm attempting to create a link for users to click that will remove them from a list. I'm trying to figure out how to do this without using a submit button and without using $_GET(if possible).
Anyway, I'm afraid to do it with $_GET (the way I have it now), because the user can type this in the URL (even though 99% wouldn't know how or think to do this) and they would be removed from the list.
How can I name the link so I can use $_POST?
$attendingUsers = mysql_query("Select acceptedInvites from events where eventID = ".mysql_real_escape_string($_GET['eventID'])." ");
$users= mysql_fetch_array($attendingUsers);
$user = $users['acceptedInvites'];
if(preg_match("/$userid/", $user)){
echo "You are attending this event</br>";
echo '<a href="viewevent.php?eventID='.$_GET['eventID'].'&delete=1">Click here </a>to remove yourself from the list';
if($_GET['delete']=1){
$sql=...
}
}
Is it possible to do this without using $_GET? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
切勿通过链接删除。阅读末日蜘蛛
最好的方法是链接到带有“你是吗”的“删除”页面确定”的形式。提交表单(通过 POST)执行删除并重定向回合适的结果页面。
例如
,然后,在
remove.php
中,您可能还应该研究 CSRF 保护,但这确实超出了这个问题的范围。
Never delete via a link. Read The Spider of Doom
Best way is to link to a "delete" page with an "are you sure" form. Submitting the form (via POST) performs the delete and redirects back to a suitable results page.
For example
Then, in
remove.php
You should probably also look into CSRF protection but that's really outside the scope of this question.
您需要使用
$_GET
或$_POST
Your are required to use either
$_GET
or$_POST
如果我的 JavaScript 正确,这应该可以解决问题:
链接将提交表单。
If I have my JavaScript right, this should do the trick:
The link will then submit the form.
您可以使用某种编码使 get var 不可读,例如 md5 甚至加密字符串。
You could use some kind of encoding to make the get var unreadable, like an md5 or even an encrypted string.