gpt4 book ai didi

php - MySQL 选择一个包含替换文本的列,它等于一个值

转载 作者:行者123 更新时间:2023-11-29 06:20:05 27 4
gpt4 key购买 nike

我最近注意到一个事实,即无论您是否放置“.”,gmail 电子邮件地址都是相同的。在“@gmail.com”之前。所以“myemail@gmail.com”和“my.email@gmail.com”都发送到“myemail@gmail.com”。

因此,当用户在我的网站上注册时,我想检查他们是否没有使用此漏洞利用基本相同的电子邮件地址创建多个帐户。

我清理了他们发给我的电子邮件地址,使用 PDO 登录到我的数据库,然后尝试运行此代码:

$data=$db->query("SELECT REPLACE(email,'.','') AS email_without_periods FROM account_data HAVING email_without_periods LIKE '".str_replace($sanitizedEmail,".","")."'");

if($row=$data->fetch()){
//It found a match between the sanitized email without decimals and the email rows without decimals. Hey, this dude's trying to create multiple accounts!
$error="You're trying the email decimal trick! You sneaky devil... ";
}

但是,这个输入不起作用:它似乎没有注册任何行。

当我用 LIKE '%".str_replace($sanitizedEmail,"."替换 LIKE '".str_replace($sanitizedEmail,".","")."'" 时"")."%'",它带回了所有行。

我基本上想在数据库中搜索 str_replace($postEmail,".",""),但首先要删除 email 行中的所有句点。我正在使用 PDO。

我该怎么做?

最佳答案

您在 str_replace 中的参数顺序错误。应该是:

str_replace('.', '', $sanitizedEmail)

您使用的参数顺序与 SQL 的 REPLACE 函数相同,但它们不同。

关于php - MySQL 选择一个包含替换文本的列,它等于一个值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33712189/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com