[英]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. 提前致谢。
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 在成功确认邮件后无法插入用户,您可以按照一些步骤来限制用户
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);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.