PHP isset GET中的唯一标识符链接值接收失败 [英] Unique identifier link value receiving failure in PHP isset GET

查看:83
本文介绍了PHP isset GET中的唯一标识符链接值接收失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过电子邮件向用户发送唯一标识符链接来验证注册.

I'm trying to verify registration via email with sending of unique identifier link to user.

我从远程服务器使用它.服务器,用户名,密码,数据库值正确,可以与其他.php -s正常工作,只有差异verify.php包含连接,而不是require 'connection.php';,但是我不确定连接是否会在失败后产生.

I use it from remote server. Server, username, password, database values are correct, works fine with other .php-s, only difference verify.php has connection included, instead require 'connection.php';, but I'm not sure if connection produces following failure.

发送:

$message = "<p>Hello, dear $user</p><a href='https://mypage.info/php/reg/verify.php?vkey=$vkey'>Confirm Account</a>";

并通过电子邮件接收:

https://mypage.info/php/reg/verify.php?vkey=4bf65cf02210b304143589e6dc3714c0

链接到verify.php,但是php抛出Something went wrong,或者 如果改为die,我将检查echo 'VKey: '. $vkey;echo $mysqli->error;什么都不显示.

link to verify.php, but php throws Something went wrong, or if instead die I'll check echo 'VKey: '. $vkey; or echo $mysqli->error; shows nothing.

似乎由于某些原因if (isset($_GET['vkey']))无法正确接收vkey.我不确定自己在做什么错:

Seems like by some reason if (isset($_GET['vkey'])) does not receives vkey correctly. I'm not sure what I'm doing wrong here:

警告!此示例代码显示了不安全的方法,因为直接从用户输入接受SQL参数.要求准备好的语句和绑定参数

推荐答案

建议:检测所有可能的内容,然后回发找到的内容.

SUGGESTION: instrument everything possible, and post back what you find.

例如:

<?php
  echo "vkey=" . $_GET['vkey'] . "...<br/>";
  if (isset($_GET['vkey'])) {
     $vkey = $_GET['vkey'];
     echo "vkey=" . $vkey . "...<br/>";
     $mysqli = NEW MySQLi ('server','username','password','db');
     echo "mysqli: SUCCEEDED...<br/>";
     $resultSet = $mysqli->query("SELECT verified, vkey FROM registration WHERE verified = 0 AND vkey = '$vkey' LIMIT 1");
     echo "resultSet: SUCCEEDED...<br/>";

     echo "resultSet->num_rows=" . $resultSet->num_rows . "...<br/>";
     if ($resultSet->num_rows == 1)
     {
         $update = $mysqli->query("UPDATE registration SET verified = 1 WHERE vkey = '$vkey' LIMIT 1");
         echo "update: SUCCEEDED...<br/>");

         if($update){
            echo "Your account has been verified. You may now login.";
         } else {
            echo $mysqli->error;
         }
     } 
     else 
     {
         echo "This account invalid or already verified";
     }
    } else {
      echo "ERROR STATE: " . $mysqli->error . "...<br/>";
     die("Something went wrong");
  }
?>

不,我想不出"...为什么md5字符串"可能是罪魁祸首.但是我认为上述工具(或类似工具)可能会帮助我们准确地确定问题发生的位置……以及如何解决问题.

And no, I can't think of "... why md5 string" could be the culprit. But I think the above instrument (or similar) might help us determine EXACTLY where the problem is occurring ... and thus how to resolve it.

'希望有帮助...

这篇关于PHP isset GET中的唯一标识符链接值接收失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆