php - 用户登录时PHP MYSQL,将密码作为变量插入到不同的数据库?
问题描述
我希望有权访问我的网站的用户能够在我的新网站上使用他们的登录凭据,而不必做任何事情,例如再次注册,所以我正在做的是,每当他们登录到我的旧网站时,这就是登录表格:
<?php
require_once(PROJECTS_PATH . '/path/to/Form.php');
class UserLogin extends Form {
var $focusFirst = 'email';
function __construct() {
parent::__construct();
$this->input('email')->required("Please enter your email (or
login).")->label("Email (or login)")->width(40);
$this->password('password')->required("Please enter your password.");
$this->link('cancel', '/user/redirect', array("style" => "padding-
right: 50px;"))->label('Cancel');
$this->submit('login'); #, array('value' => 'Login'));
require ('/path/to/scripts/updateUsers.php'); //This includes the script that creates a new user for my new site
}
}
?>
我尝试了很多不同的方法,但似乎没有成功。我能够从用户那里获取所有需要的信息,以便在我的数据库中为我的新站点创建一个新用户,但我可以'不让密码通过我想把它原始到我的 updateUsers 脚本中,在那个脚本中我正在散列它。
注意:我不能只将我的数据库用户表移动到我的新站点表,因为涉及到不同的散列。
我的 updateUsers 脚本:
<?php
$firstname = $user['first_name'];
$mail = $user['email'];
$pw = 'TestPasswor'; //I'm doing this right not which works but I need the actual user's pw otherwise this is useless
include("/path/to/password.inc"); //for hashing the pw
include("/path/to/bootstrap.inc");
$hashed_password = user_hash_password(trim($pw));
$query = sprintf("INSERT INTO test_db.users (name, pass, mail, status)
VALUES ('$firstname', '$hashed_password', '$mail', '1')",
mysql_real_escape_string($firstname),
mysql_real_escape_string($hashed_password),
mysql_real_escape_string($mail));
// Perform Query
$result = mysql_query($query);
?>
对不起,我知道这是一个很长的描述,但谢谢!
解决方案
推荐阅读
- node.js - 我可以从 Nodejs 中的 url 获取数据吗 - Messenger BOT
- html - 当我的文本变长时相邻父容器的随机移动:HTML/CSS
- ruby-on-rails - ruby -> dyld:惰性符号绑定失败:未找到符号:_rb_deprecate_constant
- python - 属性 setter 值类型不可分配给 getter 返回类型“str”与“datetime”不兼容
- java - Tomcat7.0无法部署war
- c++ - 如何为整个 2d 或 1d 向量分配一个特定值?
- kubernetes - TaskManager 和 JobManager 之间的 Flink Cluster Kubernetes Heartbeat 故障
- seccomp - 如何绕过 seccomp
- ruby-on-rails - 如何以只读模式与其他 Devise 用户共享 Rails 模型?
- reactjs - 如何将上下文提供程序与反应路由器组件一起使用?