dongxia8656 2017-04-08 02:55
浏览 54

如何在第一次单击PHP后禁用链接

i try to disable link after first click but link always enable this my code

**

$kode = md5(uniqid(rand()));
$to = $_GET['f11'];
            $headers = "From: rizka.nugroho@omg-indonesia.com
";
            $headers .= "Reply-to: $to
";
            $pesan    = "Klik link berikut untuk verifikasi dan mengaktifkan akun : ";
            $pesan    .= ROOT."active.php?email=".$_GET['f11']."&kode=$kode&username=".$_GET['f5'];

            $a = @mail($to, "Aktivasi Akun Anda", $pesan, $headers);

**

and this active.php

**$username = $_GET['username'];

    $con = new mysqli("localhost", "xxxxxxxx", "xxxxxxxxx", "xxxxxxxxxx") or die(mysqli_error());

    $d = $con->query("UPDATE login SET kode ='0', aktif='Y' WHERE username='".$username."'") or die (mysqli_error());

    if($d) {
        echo "Selamat! Member dengan username <strong>".$username."</strong> telah aktif";
    } else {
        echo "Gagal diaktifkan";
    }**

i try update kode to 0 but the link always enable can disable, can you help me

  • 写回答

1条回答 默认 最新

  • du1843 2017-04-08 04:09
    关注

    Let us consider your link be like this

    <a href="path/to/php">link</a>
    

    It is better to use a Session variable in your case.

    $kode = md5(uniqid(rand()));
    $to = $_GET['f11'];
    $_SESSION['clicked']=true;
            $headers = "From: rizka.nugroho@omg-indonesia.com
    ";
            $headers .= "Reply-to: $to
    ";
            $pesan    = "Klik link berikut untuk verifikasi dan mengaktifkan akun : ";
            $pesan    .= ROOT."active.php?email=".$_GET['f11']."&kode=$kode&username=".$_GET['f5'];
    
            $a = @mail($to, "Aktivasi Akun Anda", $pesan, $headers);
    

    In your page where you have the link ,

    <a <?php if(!isset($_SESSION['clicked']) or $_SESSION['clicked']==false)
    echo "href=path/to/php";
    else
    echo "href='javascript:void(0)'";?> >link</a>
    
    评论

报告相同问题?

悬赏问题

  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 个人网站被恶意大量访问,怎么办
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大