Php 单击“取消”时如何删除令牌

Php 单击“取消”时如何删除令牌,php,Php,如果用户单击取消,我如何获得他/她请求的令牌注意:如果单击取消,用户无需输入任何内容。特定令牌从d.b中删除,用户被重定向到index.php。我真的不知道从何处以及如何开始,所以请记住,无论如何,下面是token.php <?php error_reporting(0); session_start(); $token=$_GET['token']; include("settings.php"); connect(); if(isset ($_POST['submit'])){ $q=

如果用户单击取消,我如何获得他/她请求的令牌注意:如果单击取消,用户无需输入任何内容。特定令牌从d.b中删除,用户被重定向到index.php。我真的不知道从何处以及如何开始,所以请记住,无论如何,下面是token.php

<?php
error_reporting(0);
session_start();
$token=$_GET['token'];
include("settings.php");
connect();
if(isset ($_POST['submit'])){
$q="select email from tokens where token='".$token."' and used=0";
$r=mysql_query($q);
while($row=mysql_fetch_array($r))
   {
$email=$row['email'];
   }
If ($email!=''){
          $_SESSION['email']=$email;
}
else die("Invalid link or Password already changed  <a href='../index.php'>Click here to go back to the HOME PAGE<a/>");}
$pass=$_POST['password'];
$email=$_SESSION['email'];
if(isset($_POST['password'])&&isset($_SESSION['email']))
{
$q="update registration set password='".md5($pass)."' where email='".$email."'";
$r=mysql_query($q);
if($r)mysql_query("update tokens set used=1 where token='".$token."'");echo "Your password is changed successfully  <a href='../index.php'>Click here to go back to the HOME PAGE<a/>";
if(!$r)echo "An error occurred";
    }
像这样的东西

$token = mysql_real_escape_string($_GET['token']);
mysql_query("DELETE FROM tokens WHERE token='$token'") or die (mysql_error());
header("Location: index.php");

如果令牌被发布到页面中,那么您想如何取消它?与您的问题无关:您的脚本易受跨站点脚本攻击,如果您的服务器上没有Magic quotes,则可能易受SQL注入攻击。创建一个javascript回调,当单击取消时,通过ajax/remove/token/:id调用该回调?我对这个问题感到困惑。abt神奇的引语我会研究它谢谢现在我的意思是,如果用户决定他/她不想更改密码,那么他们可以取消it@BjoernRennhak谢谢但我需要从d.b中删除令牌,而不需要用户输入任何内容,因为令牌来自d.bAhh,这是一个很难猜测的长随机字符串。当然。:)是的,那么你能提出什么建议呢?请接受我的建议?只要令牌是不可猜测的,你就不需要做任何其他事情。我的意思是,如果用户想要取消,我的答案不是这样做的吗?
$token = mysql_real_escape_string($_GET['token']);
mysql_query("DELETE FROM tokens WHERE token='$token'") or die (mysql_error());
header("Location: index.php");