PHP破坏了验证链接参数的开始


PHP mangles beginning of verification link parameters

我已经为此奋斗了24个多小时。我已经设置了我的服务器来设置用户帐户,并通过电子邮件向他们发送验证链接。一切都很好,但我在使用从mySql数据库派生的值的两个字符串变量hash和token时遇到了问题。每次电子邮件生成时,这些变量都会解析其数据,其中前三个字符被弄乱:

http://verify.myserver.com/objects/1.8.12.7.10.1.9/verify-email.php?mm_function=submit&hashü41faa912dd9451a8d397fc9386ca1c69&mm_tokenü2rnjrcbhn3qegtu46np03p5pg6aczbtrs51782fkuwq2c8w9m80enutwruydwewca&mm_timezone=2&mm_charset=utf-8

链接应该是:

http://verify.myserver.com/objects/1.8.12.7.10.1.9/verify-email.php?mm_function=submit&hash=fc41faa912dd9451a8d397fc9386ca1c69&mm_token=fc22rnjrcbhn3qegtu46np03p5pg6aczbtrs51782fkuwq2c8w9m80enutwruydwewca&mm_timezone=2&mm_charset=utf-8

我尝试过混合和匹配代码,但没有成功。目前,我的代码如下:

$weblink = "http://verify.myserver.com/objects/1.8.12.7.10.1.9/verify-email.php?";
$weblink . "mm_function=submit&hash=" . $hash . "&mm_token=" . $token . "&mm_timezone=" . $timezone . "&mm_charset=utf-8";

奇怪的是,如果我只是把$hash和$token作为电子邮件的一部分,独立于链接,它们都会很好。

我使用的是运行InnoDB引擎的mySql,DB排序规则是latin7_general_ci。

谢谢。

事实证明,电子邮件编码是罪魁祸首。多亏了oktopus,我在标题中使用charset=iso-8859-1修复了它,如下所示:

if (!defined("PHP_EOL")) define("PHP_EOL", "'r'n");
$headers = "From: Some Sender <someone@example.com>". PHP_EOL;
$headers.= "Return-Path: Some Sender <someone@example.com>". PHP_EOL;
$headers.= "Organization: My Organization>". PHP_EOL; 
$headers.= "Content-type: text/plain; charset=iso-8859-1". PHP_EOL;
$headers.= "MIME-Version: 1.0". PHP_EOL;
$headers.= "X-Priority: 3". PHP_EOL;
$weblink = "http://verify.myserver.com/objects/1.8.12.7.10.1.9/process.php?mm_function=submit&";
$weblink.= "mm_hash=$hash&mm_token=$verification&mm_timezone=$timezone&mm_charset=iso-8859-1";
mail($recipient, "Account Verification Link", "Hello $recipient,". PHP_EOL . PHP_EOL ."Please follow the link below to verify and activate your account:". PHP_EOL . PHP_EOL . $weblink . PHP_EOL . PHP_EOL . "Thank you.". PHP_EOL . PHP_EOL . "App Support Team", $headers);