Php 为什么我在激活电子邮件时不断出现缺少链接的错误

Php 为什么我在激活电子邮件时不断出现缺少链接的错误,php,Php,我已经做了一个电子邮件激活,这是工作,但我试图采用我的反垃圾邮件激活相同的概念。这对一些人来说是可行的,但有时,我总是发现其中一个变量没有设置,只是一个尝试和错误的东西 我还从某个地方读到,在isset()检查之后,我也应该包括一个非空检查 <?php include_once __DIR__.'/header2.php'; if(isset($_SESSION['u_uid'])) { echo "<meta http-equiv='refresh' content='0;

我已经做了一个电子邮件激活,这是工作,但我试图采用我的反垃圾邮件激活相同的概念。这对一些人来说是可行的,但有时,我总是发现其中一个变量没有设置,只是一个尝试和错误的东西

我还从某个地方读到,在isset()检查之后,我也应该包括一个非空检查

<?php
include_once __DIR__.'/header2.php';
if(isset($_SESSION['u_uid'])) {
    echo "<meta http-equiv='refresh' content='0;url=../header2.php?reply=mustloggedoutfirst'>"; 
    exit();
} else {
if(!isset($_GET['email']) && $_GET['email'] !== '' || !isset($_GET['userid']) && $_GET['userid'] !== '' || !isset($_GET['id']) && $_GET['id'] !== '' || !isset($_GET['reply_registration_expirydate']) && $_GET['reply_registration_expirydate'] !== '') {
    echo "<meta http-equiv='refresh' content='0;url=../index.php?reply=missinglink'>"; 
    exit();
} else {
    $email = strip_tags($_GET['email']);
    $username = strip_tags($_GET['userid']);
    $id = strip_tags($_GET['id']);
    $reply_registration_expirydate = strip_tags($_GET['reply_registration_expirydate']);

    if (empty($_SESSION['key'])) {
        $_SESSION['key'] = base64_encode(openssl_random_pseudo_bytes(32));
      }

}
}

更新IF子句并删除“isset”的否定


使用“!isset($\u GET['email'])&&&$\u GET['email']!==''检查变量是否未设置,然后(未设置)如果变量不等于空字符串,则必须遇到“variable NOT set”-错误。

if语句的逻辑顺序可能不正确。“缺少链接错误”可能是指执行if语句的这一部分:

if(!isset($_GET['email']) && $_GET['email'] !== '' || !isset($_GET['userid']) && $_GET['userid'] !== '' || !isset($_GET['id']) && $_GET['id'] !== '' || !isset($_GET['reply_registration_expirydate']) && $_GET['reply_registration_expirydate'] !== '') {
格式:

if (! isset($_GET['email'])                             //        IS NOT SET email
  && $_GET['email'] !== ''                              // and    IS NOT EMPTY email
  || !isset($_GET['userid'])                            // or     IS NOT SET userid
  && $_GET['userid'] !== ''                             // and    IS NOT EMPTY userid
  || !isset($_GET['id'])                                // or     IS NOT SET id
  && $_GET['id'] !== ''                                 // and    IS NOT EMPTY id
  || !isset($_GET['reply_registration_expirydate'])     // or     IS NOT SET reply_registration_expirydate
  && $_GET['reply_registration_expirydate'] !== '') {   // and    IS NOT EMPTY reply_registration_expirydate
由于错误,您的语句可能比您希望的更早计算为true。您需要使用括号对操作数进行分组

if ((! isset($_GET['email'])                             //        (IS NOT SET email
  && $_GET['email'] !== '')                              // and    IS NOT EMPTY email)
  || (!isset($_GET['userid'])                            // or     (IS NOT SET userid
  && $_GET['userid'] !== '')                             // and    IS NOT EMPTY userid)
  || (!isset($_GET['id'])                                // or     (IS NOT SET id
  && $_GET['id'] !== '')                                 // and    IS NOT EMPTY id)
  || (!isset($_GET['reply_registration_expirydate'])     // or     (IS NOT SET reply_registration_expirydate
  && $_GET['reply_registration_expirydate'] !== '')) {   // and    IS NOT EMPTY reply_registration_expirydate)

道歉。。。然后,我认为如果变量未设置且为空$email=strip_标记($_GET['email']),则应该是这样$username=strip_标记($_GET['userid'])$id=带标签($获取['id'])$reply_registration_expirydate=带标签($_GET['reply_registration_expirydate']);我需要在这里使用strip_标签吗?可以在这里使用吗?正如我说的:删除否定。如果未设置,则无需检查它是否为空。strip_标记与此无关。如果未检测到错误,除了设置会话变量
键之外,代码应该做什么?是否有基于该会话变量的后续代码?
if ((! isset($_GET['email'])                             //        (IS NOT SET email
  && $_GET['email'] !== '')                              // and    IS NOT EMPTY email)
  || (!isset($_GET['userid'])                            // or     (IS NOT SET userid
  && $_GET['userid'] !== '')                             // and    IS NOT EMPTY userid)
  || (!isset($_GET['id'])                                // or     (IS NOT SET id
  && $_GET['id'] !== '')                                 // and    IS NOT EMPTY id)
  || (!isset($_GET['reply_registration_expirydate'])     // or     (IS NOT SET reply_registration_expirydate
  && $_GET['reply_registration_expirydate'] !== '')) {   // and    IS NOT EMPTY reply_registration_expirydate)