简体   繁体   English

电子邮件确认后如何将用户添加到数据库?

[英]How to add user to database after email confirmation?

I have a website built with PHP Codeigniter framework. 我有一个使用PHP Codeigniter框架构建的网站。 It has an user management system. 它具有一个用户管理系统。 Generally, what it does is, when an user registers, it add his information to database and sends a conformation email(like other systems). 通常,它的作用是,当用户注册时,它将其信息添加到数据库中并发送确认电子邮件(类似于其他系统)。

But now some spammers are creating lots of accounts. 但是现在,一些垃圾邮件发送者正在创建大量帐户。 They don't verify the email though. 他们虽然不验证电子邮件。 Just add more records to the database. 只需将更多记录添加到数据库。 However, my database is getting heavy for this. 但是,我的数据库为此变得越来越繁重。 How can I prevent this? 我该如何预防?

Is there any workflow by which I can add an user after his email confirmation? 确认用户后,是否可以通过任何工作流程添加用户?

Thanks in advance. 提前致谢。

  • You can add some captcha or security as say in comment's. 您可以添加一些验证码或安全性,如评论中所述。
  • You can also, with codeigniter, easily get the user ip with the function ip_adress and limit the creation of an account by ip. 您还可以使用codeigniter通过功能ip_adress轻松获得用户ip并限制通过ip创建帐户。
  • Set a cron function to disable inactivated accounts everyday/week to lighter you database with useless account... 设置cron功能以每天/每周禁用未激活的帐户,以减轻您使用无用帐户的数据库的负担...
  • Use Analitics and see where the spam come from, and blacklist the concerned countries. 使用Analitics,查看垃圾邮件的来源,并将相关国家/地区列入黑名单。

There is many solutions but none of them is perfect or 100% effective :/ 有许多解决方案,但都不是完美的解决方案或100%有效的解决方案:/

it is not possible to insert the user after sucessfully confirmation mail you can follow some steps to restrict the users 在成功确认邮件后无法插入用户,您可以按照一些步骤来限制用户

  1. create a captcha in your registration form 在您的注册表中创建一个验证码
  2. make a new table ie blueprint of your registration table so the user register go to this new table then if the user is confirm there mail then the record move to orginal registation table and delete from the new one 制作一个新表,即您的注册表的蓝图,以便用户注册转到该新表,然后如果用户确认有邮件,则记录移至原始注册表并从新表中删除
  3. to blok the user by one user one ip is not a good solution so don't restrict them 用一个IP来让一个用户拥挤用户不是一个好的解决方案,所以不要限制他们
  4. just run a cron job on every 3 day on the new blueprint of the table so the users that is not confirm their mail simply remove all the entries from the new table on every three days on every week. 只需在表的新蓝图上每3天运行一次cron作业,这样不确定邮件的用户就可以每周每三天从新表中删除所有条目。 thats it Thanks. 就是这样,谢谢。

PDO Prepared Statements validate function PDO准备语句验证功能

$result = Database::getInstance()->query("SELECT * FROM user ORDER BY id DESC WHERE 1");

this should get you the last database entry now you should read out the verification status and delete unverified user or add veriefied user 这应该为您提供最后一个数据库条目,现在您应该读出验证状态并删除未验证的用户或添加已验证的用户

in your Database class you should have a functin that buils your sql query and build a array with the values you want to inject 在您的Database类中,您应该有一个functin可以构建您的sql查询并使用您要注入的值构建一个数组

public function query($query, array $parameters = array())
{
    $statement = $this->connection->prepare($query);

    foreach($parameters as $key => $value)
    {
        $statement->bindValue(':'.$key, $value);
    }

    $statement->execute();
    return $statement->fetchAll(PDO::FETCH_ASSOC);
}
  • Best Solution is to use Google reCaptcha 最好的解决方案是使用Google reCaptcha
  • Use Check for E-Mail address legal validation 使用“检查电子邮件地址”合法性验证

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 PHP-将电子邮件添加到数据库中,发送确认电子邮件并重定向 - PHP - add email into database , send confirmation email and redirect 条纹:如何获取用户电子邮件(和/或其他信息)以及付款后重定向到确认页面? - Stripe: how to get user email (and/or other info) and after payment redirect to a confirmation page? 发送用户和管理员确认电子邮件 - Send user and admin confirmation email 用户注册后如何发送验证/确认电子邮件 - How to send Verification/Confirmation Email when user have registered 如何制作联系表向用户发送确认电子邮件? - How to make a contact form send a confirmation email to the user? 当商店用户在Sylius进行电子邮件确认时,如何收听事件? - How to listen to the event when a shop user is doing email confirmation at Sylius? 如何使用户注册确认电子邮件安全? - How can I make a user registration confirmation email secure? 用户确认后在正则表达式匹配项周围添加括号的shell脚本 - shell script to add parentheses around regex matches after user confirmation 提交表单后如何向发件人和我发送确认电子邮件 - How to send a confirmation email to sender and to me after form submission 几秒钟后如何在php中禁用电子邮件确认链接 - How to disable the email confirmation link after few seconds in php
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM